Skip to content

Commit

Permalink
add script to fetch stats
Browse files Browse the repository at this point in the history
  • Loading branch information
gantoine committed Jan 4, 2025
1 parent 599e956 commit 683b5e7
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 1 deletion.
79 changes: 79 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"build": "nuxt build",
"dev": "nuxt dev",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
"postinstall": "nuxt prepare",
"fetch-stats": "node scripts/fetch-stats.js"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.5.2",
Expand All @@ -20,6 +21,7 @@
"devDependencies": {
"@nuxt/image": "^1.7.0",
"@nuxtjs/tailwindcss": "^6.12.0",
"axios": "^1.7.9",
"nuxt": "^3.12.4",
"nuxt-primevue": "^0.3.1",
"vue": "^3.4.27",
Expand Down
57 changes: 57 additions & 0 deletions scripts/fetch-stats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import axios from "axios";

// GitHub repository details
const owner = "rommapp";
const repo = "romm";
const image = "rommapp/romm";

// Fetch the latest release from GitHub
async function fetchLatestRelease() {
try {
const response = await axios.get(
`https://api.github.com/repos/${owner}/${repo}/releases/latest`,
);
return response.data.tag_name;
} catch (error) {
console.error("Error fetching latest release:", error.message);
process.exit(1);
}
}

// Fetch the star count from GitHub
async function fetchGitHubStars() {
try {
const response = await axios.get(
`https://api.github.com/repos/${owner}/${repo}`,
);
return response.data.stargazers_count.toLocaleString(); // Format with commas
} catch (error) {
console.error("Error fetching GitHub stars:", error.message);
process.exit(1);
}
}

// Fetch the pull count from Docker Hub
async function fetchDockerPulls() {
try {
const response = await axios.get(
`https://hub.docker.com/v2/repositories/${image}`,
);
return response.data.pull_count.toLocaleString(); // Format with commas
} catch (error) {
console.error("Error fetching Docker Hub pull count:", error.message);
process.exit(1);
}
}

// Main function to run the update
(async function main() {
const latestVersion = await fetchLatestRelease();
console.log(`Latest GitHub version: ${latestVersion}`);

const githubStars = await fetchGitHubStars();
console.log(`GitHub stars: ${githubStars}`);

const dockerPulls = await fetchDockerPulls();
console.log(`Docker Hub pulls: ${dockerPulls}`);
})();

0 comments on commit 683b5e7

Please sign in to comment.