Skip to content

Instantly share code, notes, and snippets.

@SgtPooki
Last active November 7, 2023 01:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SgtPooki/125b0f30d12bc19fc799e78c317955e1 to your computer and use it in GitHub Desktop.
Save SgtPooki/125b0f30d12bc19fc799e78c317955e1 to your computer and use it in GitHub Desktop.
This script requires a markdown table for input, as generated by https://github.com/nvuillam/github-dependents-info. It compares the current table with the previous one and outputs a new table with the changes in stars.
#!/usr/bin/env node
/**
* This script requires a markdown table for input, as generated by https://github.com/nvuillam/github-dependents-info
* It compares the current table with the previous one and outputs a new table with the changes in stars.
* Usage:
* github-dependents-info --repo ipfs/helia --markdownfile ./package-usage-2023-09.md --sort stars --verbose -x 2 -p
* // manually copy the Repostory and Stars table to `current.md`
* // manually copy the Repostory and Stars table from the previous month to `previous.md`
* node dependents-change.js
*
* This is used to generate the table in Helia reports, like at https://pl-strflt.notion.site/Helia-Report-2023-09-892d8510e49549b6b96fd87323c0c715#2b2d82cd734e45fab4c6b6549cb06e2c
*/
import fs from 'node:fs'
// read the previous table from `previous.md`
const previousMonthTable = fs.readFileSync('previous.md', 'utf8');
const currentMonthTable = fs.readFileSync('current.md', 'utf8');
// Function to parse a Markdown table and create an object
function parseMarkdownTable(table) {
const lines = table.trim().split('\n');
const header = lines[1].split('|').map(cell => cell.trim()).filter(Boolean);
const data = {};
for (let i = 2; i < lines.length; i++) {
const row = lines[i].split('|').map(cell => cell.trim()).filter(Boolean);
if (row.length === header.length) {
data[row[0].toLowerCase()] = parseInt(row[1].toLowerCase());
}
}
// make sure all keys are github urls only so we can compare them correctly.
// i.e. convert from something like `[linkName](url)` to just `url`
for (const key in data) {
const match = key.match(/\[.*\]\((.*)\)/);
if (match) {
data[match[1]] = data[key];
delete data[key];
}
}
return data;
}
// Parse the tables and create objects
const previousMonthData = parseMarkdownTable(previousMonthTable);
const currentMonthData = parseMarkdownTable(currentMonthTable);
// Find new repositories and changes in stars
const changesInStars = {};
for (const repository in previousMonthData) {
if (repository in currentMonthData) {
const starChange = currentMonthData[repository] - previousMonthData[repository];
changesInStars[repository] = starChange;
}
}
// Prepare and log the result in Markdown format with clickable links
console.log('| Repository | Stars | Change |');
console.log('| --- | --- | --- |');
for (const repository in currentMonthData) {
const starsCurrent = currentMonthData[repository];
const change = changesInStars[repository] ?? 'NEW';
const repoName = repository.replace('https://github.com/', '').replace('/', '/');
const repoLink = `[${repoName}](${repository})`;
console.log(`| ${repoLink} | ${starsCurrent} | ${change} |`);
}
{
"name": "@SgtPooki/dependents-change",
"version": "1.0.1",
"bin": "./dependents-change.js",
"type": "module"
}
@SgtPooki
Copy link
Author

SgtPooki commented Nov 7, 2023

October report current.md output:

| Repository | Stars  |
| :--------  | -----: |
|[ipfs/ipfs-webui](https://github.com/ipfs/ipfs-webui) | 1477 |
|[ipfs/helia](https://github.com/ipfs/helia) | 532 |
|[yazz/yazz](https://github.com/yazz/yazz) | 519 |
|[cyph/cyph](https://github.com/cyph/cyph) | 365 |
|[ipld/explore.ipld.io](https://github.com/ipld/explore.ipld.io) | 112 |
|[darrylyeo/blockhead](https://github.com/darrylyeo/blockhead) | 84 |
|[ipfs/js-datastore-s3](https://github.com/ipfs/js-datastore-s3) | 72 |
|[usecannon/cannon](https://github.com/usecannon/cannon) | 67 |
|[iohzrd/identia](https://github.com/iohzrd/identia) | 65 |
|[pinnacle-labs/taqueria](https://github.com/pinnacle-labs/taqueria) | 62 |
|[LibertyDSNP/frequency](https://github.com/LibertyDSNP/frequency) | 43 |
|[ipfs-examples/helia-examples](https://github.com/ipfs-examples/helia-examples) | 33 |
|[hldb/welo](https://github.com/hldb/welo) | 26 |
|[orochi-network/zkDatabase](https://github.com/orochi-network/zkDatabase) | 25 |
|[ipfs/ipld-explorer-components](https://github.com/ipfs/ipld-explorer-components) | 23 |
|[sanchezcarlosjr/evanotebook](https://github.com/sanchezcarlosjr/evanotebook) | 14 |
|[tabcat/dynamic-content](https://github.com/tabcat/dynamic-content) | 14 |
|[yayacat/TREM](https://github.com/yayacat/TREM) | 13 |
|[ipfs/js-stores](https://github.com/ipfs/js-stores) | 13 |
|[sunodo/sunodo](https://github.com/sunodo/sunodo) | 11 |
|[tabcat/zzzync](https://github.com/tabcat/zzzync) | 11 |
|[ipfs/helia-unixfs](https://github.com/ipfs/helia-unixfs) | 11 |
|[esdt-space/mx-dapp-template](https://github.com/esdt-space/mx-dapp-template) | 9 |
|[HybridWare/zero-browser](https://github.com/HybridWare/zero-browser) | 8 |
|[polus-arcticus/obsidian-lilypad](https://github.com/polus-arcticus/obsidian-lilypad) | 8 |
|[ipfs-shipyard/helia-service-worker-gateway](https://github.com/ipfs-shipyard/helia-service-worker-gateway) | 7 |
|[ipfs/helia-ipns](https://github.com/ipfs/helia-ipns) | 7 |
|[Permissionless-Software-Foundation/ipfs-service-provider](https://github.com/Permissionless-Software-Foundation/ipfs-service-provider) | 6 |
|[BigDog1400/code0](https://github.com/BigDog1400/code0) | 6 |
|[scobru/mecenate-monorepo](https://github.com/scobru/mecenate-monorepo) | 6 |
|[carllippert/SecretAgents](https://github.com/carllippert/SecretAgents) | 6 |
|[vmx/colleemap](https://github.com/vmx/colleemap) | 5 |
|[mbcse/web3stash](https://github.com/mbcse/web3stash) | 5 |
|[ipfs/helia-json](https://github.com/ipfs/helia-json) | 5 |
|[SgtPooki/helia-playground](https://github.com/SgtPooki/helia-playground) | 4 |
|[ansi-code/ipdw](https://github.com/ansi-code/ipdw) | 4 |
|[ipfs/helia-car](https://github.com/ipfs/helia-car) | 4 |
|[ipfs/helia-dag-cbor](https://github.com/ipfs/helia-dag-cbor) | 4 |
|[ipfs/helia-strings](https://github.com/ipfs/helia-strings) | 4 |
|[aspiringsecurity/EMTTR](https://github.com/aspiringsecurity/EMTTR) | 3 |
|[botfi-app/botfi-wallet](https://github.com/botfi-app/botfi-wallet) | 3 |
|[ipfs-shipyard/www-helia-identify](https://github.com/ipfs-shipyard/www-helia-identify) | 3 |
|[ipfs/helia-mfs](https://github.com/ipfs/helia-mfs) | 3 |
|[face-protocol/app](https://github.com/face-protocol/app) | 3 |
|[ocdbytes/IPFS_DUMP_REPO](https://github.com/ocdbytes/IPFS_DUMP_REPO) | 3 |
|[hldb/todomvc](https://github.com/hldb/todomvc) | 3 |
|[ipfs/helia-dag-json](https://github.com/ipfs/helia-dag-json) | 3 |
|[nftstudio-24/nftstudio24-ICP](https://github.com/nftstudio-24/nftstudio24-ICP) | 2 |
|[noryev/LargeFieldDataAnalyzer](https://github.com/noryev/LargeFieldDataAnalyzer) | 2 |
|[Obsidian-Desci/Obsidian-Desci](https://github.com/Obsidian-Desci/Obsidian-Desci) | 2 |
|[ipfs-shipyard/www-helia-io](https://github.com/ipfs-shipyard/www-helia-io) | 2 |
|[ipfs/helia-http-gateway](https://github.com/ipfs/helia-http-gateway) | 2 |
|[ronykris/dapilink](https://github.com/ronykris/dapilink) | 2 |
|[polus-arcticus/helia-pubsub-webrtc](https://github.com/polus-arcticus/helia-pubsub-webrtc) | 2 |
|[NAKITARE00/ETHSAFARIDAOMEDYAPP](https://github.com/NAKITARE00/ETHSAFARIDAOMEDYAPP) | 2 |
|[avasdao/nexa-garden](https://github.com/avasdao/nexa-garden) | 2 |
|[danimbrogno/union-dao](https://github.com/danimbrogno/union-dao) | 2 |
|[magomedov-b/bashir_nft_marketplace](https://github.com/magomedov-b/bashir_nft_marketplace) | 2 |
|[programmeruser2/Cosmic](https://github.com/programmeruser2/Cosmic) | 2 |
|[awesome-abstraction/waas-pay](https://github.com/awesome-abstraction/waas-pay) | 2 |
|[open-predict/OpenPredict](https://github.com/open-predict/OpenPredict) | 2 |
|[arosboro/newsletter-fe](https://github.com/arosboro/newsletter-fe) | 2 |
|[frontline-hq/web3db](https://github.com/frontline-hq/web3db) | 2 |
|[subvisual/CosmicWave-fe](https://github.com/subvisual/CosmicWave-fe) | 2 |
|[md0x/defikicks](https://github.com/md0x/defikicks) | 2 |
|[HomoSimulo/NFT-TD](https://github.com/HomoSimulo/NFT-TD) | 2 |
|[mmsaki/star-streamer](https://github.com/mmsaki/star-streamer) | 2 |
|[SgtPooki/helia-service-worker-gateway](https://github.com/SgtPooki/helia-service-worker-gateway) | 2 |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment