diff --git a/package-lock.json b/package-lock.json index 71aa5d0..902d3b4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,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", @@ -3637,6 +3638,12 @@ "integrity": "sha512-tLRNUXati5MFePdAk8dw7Qt7DpxPB60ofAgn8WRhW6a2rcimZnYBP9oxHiv0OHy+Wz7kPMG+t4LGdt31+4EmGg==", "dev": true }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true + }, "node_modules/at-least-node": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", @@ -3683,6 +3690,17 @@ "postcss": "^8.1.0" } }, + "node_modules/axios": { + "version": "1.7.9", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz", + "integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==", + "dev": true, + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "node_modules/b4a": { "version": "1.6.6", "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.6.tgz", @@ -4332,6 +4350,18 @@ "integrity": "sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw==", "dev": true }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/commander": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", @@ -4876,6 +4906,15 @@ "integrity": "sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==", "dev": true }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", @@ -5332,6 +5371,26 @@ "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", "dev": true }, + "node_modules/follow-redirects": { + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, "node_modules/foreground-child": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", @@ -5360,6 +5419,20 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/form-data": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", + "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fraction.js": { "version": "4.3.7", "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.7.tgz", @@ -8998,6 +9071,12 @@ "integrity": "sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q==", "dev": true }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "dev": true + }, "node_modules/pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", diff --git a/package.json b/package.json index a5966fe..3c01935 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/scripts/fetch-stats.js b/scripts/fetch-stats.js new file mode 100644 index 0000000..8046902 --- /dev/null +++ b/scripts/fetch-stats.js @@ -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}`); +})();