Compare commits

...

10 Commits

Author SHA1 Message Date
da1df6e13a initial commit
All checks were successful
Build and Push Docker Image / docker (push) Successful in 7m22s
2025-08-24 16:21:28 -07:00
Nikos Kanakis
366f8b9dfe docs: make github action workflow more understandable (#1582) [skip ci] 2023-12-18 18:04:44 +01:00
Ilan
995dd4a8e1 fix(plugins/languages): support for private repositories (#1579) 2023-12-18 18:01:01 +01:00
github-actions[bot]
a53a5853a9 chore: code formatting 2023-11-14 02:26:48 +00:00
Simon Lecoq
13a071e529 chore: rebuild files 2023-11-13 20:46:03 -05:00
Simon Lecoq
84df066c49 Update .gitignore 2023-11-13 20:39:30 -05:00
Simon Lecoq
08f1719ee0 chore(deps): disable npm dependabot as v4 won't use npm anymore 2023-10-31 06:24:59 +01:00
Simon Lecoq
d75fc5fbde fix: add missing partial 2023-10-11 00:54:51 +00:00
Thanh Tran
9f08a38cc0 feat: add plugins crypto (#1535) 2023-10-07 15:44:19 +02:00
Movrsi
c430d64381 fic(docs): correct metric image centering. (#1541) 2023-10-05 03:57:36 +02:00
24 changed files with 586 additions and 56 deletions

View File

@@ -0,0 +1,67 @@
name: Build and Push Docker Image
on:
push:
branches:
- "master"
- "release/*"
tags:
- "*"
workflow_dispatch:
jobs:
docker:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Ensure full history and all tags are available
fetch-depth: 0
- name: Set up QEMU (multi-arch)
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: gitea.suda.codes/${{ github.repository }}
tags: |
type=ref,event=tag
- name: Determine latest Git tag
id: latest
shell: bash
run: |
set -euo pipefail
# Fetch tags in case the runner's mirror is stale
git fetch --tags --force --quiet || true
if tag=$(git describe --tags --abbrev=0 2>/dev/null); then
echo "tag=$tag" >> "$GITHUB_OUTPUT"
else
# Fallback when no tags exist
echo "tag=latest" >> "$GITHUB_OUTPUT"
fi
- name: Log in to container registry
uses: docker/login-action@v3
with:
registry: gitea.suda.codes
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
# Always tag with the latest Git tag; also keep any tags from metadata (e.g., on tag events)
tags: |
${{ steps.meta.outputs.tags }}
gitea.suda.codes/${{ github.repository }}:${{ steps.latest.outputs.tag }}

View File

@@ -1,6 +1,7 @@
version: 2
updates:
- package-ecosystem: npm
open-pull-requests-limit: 0 # Will not be managed by npm anymore in v4
labels:
- 📦 dependencies
directory: /

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 89 KiB

View File

@@ -68,6 +68,8 @@ on:
jobs:
github-metrics:
runs-on: ubuntu-latest
environment:
name: production
permissions:
contents: write
steps:
@@ -127,7 +129,7 @@ Update profile `README.md` to include rendered image (filename may differ if `fi
*Example: add rendered image with html for more customization*
```html
<img align="center" src="/github-metrics.svg" alt="Metrics" width="400">
<p align="center"><img src="/github-metrics.svg" alt="Metrics" width="400"></p>
```
*Example: add rendered image and prevent GitHub from auto linking to the image*

10
.gitignore vendored
View File

@@ -114,4 +114,12 @@ source/templates/@*
source/app/web/statics/preview
# Presets
.presets
.presets
# V4
.deno-make.json
.coverage
.secrets
.test
source/run/serve/static/app.js
metrics.config.yml

View File

@@ -1,37 +1,59 @@
# Base image
FROM node:20-bookworm-slim
# Copy repository
COPY . /metrics
WORKDIR /metrics
# Setup
RUN chmod +x /metrics/source/app/action/index.mjs \
# Install latest chrome dev package, fonts to support major charsets and skip chromium download on puppeteer install
# Based on https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker
&& apt-get update \
&& apt-get install -y wget gnupg ca-certificates libgconf-2-4 \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 libx11-xcb1 libxtst6 lsb-release --no-install-recommends \
# Install deno for miscellaneous scripts
&& apt-get install -y curl unzip \
&& curl -fsSL https://deno.land/x/install/install.sh | DENO_INSTALL=/usr/local sh \
# Install ruby to support github licensed gem
&& apt-get install -y ruby-full git g++ cmake pkg-config libssl-dev \
&& gem install licensed \
# Install python for node-gyp
&& apt-get install -y python3 \
# Clean apt/lists
&& rm -rf /var/lib/apt/lists/* \
# Install node modules and rebuild indexes
&& npm ci \
&& npm run build
# Install Google Chrome stable and runtime deps + fonts
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
wget gnupg ca-certificates curl unzip \
# Chrome runtime deps
libnss3 libxss1 libx11-xcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 \
libxkbcommon0 libxrandr2 libatk1.0-0 libatk-bridge2.0-0 libgtk-3-0 \
libgbm1 libasound2 fonts-liberation \
# Optional fonts for broader charset support
fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf; \
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/google-linux.gpg; \
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-linux.gpg] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list; \
apt-get update; \
apt-get install -y --no-install-recommends google-chrome-stable; \
rm -rf /var/lib/apt/lists/*
# Environment variables
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV PUPPETEER_BROWSER_PATH "google-chrome-stable"
# Prevent Puppeteer from downloading Chromium, point to system Chrome
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome-stable
# Execute GitHub action
ENTRYPOINT node /metrics/source/app/action/index.mjs
# Default Chrome args suitable for containers (headless + no sandbox)
ENV CHROME_DEFAULT_ARGS="--no-sandbox --disable-setuid-sandbox --headless=new --disable-gpu --disable-dev-shm-usage --no-zygote --no-first-run --ozone-platform=none --disable-features=UseOzonePlatform --enable-features=NetworkService,NetworkServiceInProcess"
# Env consumed by lowlighter/metrics to pass browser flags
ENV METRICS_BROWSER=chromium
ENV METRICS_BROWSER_HEADLESS=true
ENV METRICS_BROWSER_ARGS=""
# Optional: trust reverse proxy for express-rate-limit
ENV METRICS_TRUST_PROXY=1
# Copy sources and install JS deps
COPY package.json package-lock.json* ./
RUN npm ci
COPY . .
# Build the project
RUN npm run build
# Wrapper entrypoint to ensure args are always set
RUN printf '%s\n' \
'#!/usr/bin/env bash' \
'set -euo pipefail' \
'export PUPPETEER_EXECUTABLE_PATH="${PUPPETEER_EXECUTABLE_PATH:-/usr/bin/google-chrome-stable}"' \
'export METRICS_BROWSER="${METRICS_BROWSER:-chromium}"' \
'export METRICS_BROWSER_HEADLESS="${METRICS_BROWSER_HEADLESS:-true}"' \
'if [ -z "${METRICS_BROWSER_ARGS:-}" ]; then' \
' export METRICS_BROWSER_ARGS="${CHROME_DEFAULT_ARGS}"' \
'fi' \
'exec npm start' \
> /usr/local/bin/metrics-entrypoint && chmod +x /usr/local/bin/metrics-entrypoint
ENTRYPOINT ["/usr/local/bin/metrics-entrypoint"]

View File

@@ -19,7 +19,7 @@ Generate metrics that can be embedded everywhere, including your GitHub profile
</tr>
<tr>
<th colspan="2" align="center">
<h3><a href="/README.md#-plugins">🧩 Customizable with 46 plugins and 330 options!</a></h3>
<h3><a href="/README.md#-plugins">🧩 Customizable with 47 plugins and 335 options!</a></h3>
</th>
</tr>
<tr>
@@ -323,46 +323,56 @@ Generate metrics that can be embedded everywhere, including your GitHub profile
</th>
</tr>
<tr>
<th><a href="source/plugins/community/crypto/README.md">🪙 Crypto</a><br><sup>by <a href="https://github.com/dajneem23">@dajneem23</a></sup>
<details><summary>Render example</summary>
<img alt="" width="400" src="https://via.placeholder.com/468x60?text=No%20preview%20available" alt=""></img>
<img width="900" height="1" alt="">
</details>
</th>
<th><a href="source/plugins/community/fortune/README.md">🥠 Fortune</a><br><sup>by <a href="https://github.com/lowlighter">@lowlighter</a></sup>
<details><summary>Render example</summary>
<img alt="" width="400" src="https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.fortune.svg" alt=""></img>
<img width="900" height="1" alt="">
</details>
</th>
</tr>
<tr>
<th><a href="source/plugins/community/nightscout/README.md">💉 Nightscout</a><br><sup>by <a href="https://github.com/legoandmars">@legoandmars</a></sup>
<details><summary>Render example</summary>
<img alt="" width="400" src="https://github.com/legoandmars/legoandmars/blob/master/metrics.plugin.nightscout.svg" alt=""></img>
<img width="900" height="1" alt="">
</details>
</th>
</tr>
<tr>
<th><a href="source/plugins/community/poopmap/README.md">💩 PoopMap plugin</a><br><sup>by <a href="https://github.com/matievisthekat">@matievisthekat</a></sup>
<details><summary>Render example</summary>
<img alt="" width="400" src="https://github.com/matievisthekat/matievisthekat/blob/master/metrics.plugin.poopmap.svg" alt=""></img>
<img width="900" height="1" alt="">
</details>
</th>
</tr>
<tr>
<th><a href="source/plugins/community/screenshot/README.md">📸 Website screenshot</a><br><sup>by <a href="https://github.com/lowlighter">@lowlighter</a></sup>
<details><summary>Render example</summary>
<img alt="" width="400" src="https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.screenshot.svg" alt=""></img>
<img width="900" height="1" alt="">
</details>
</th>
</tr>
<tr>
<th><a href="source/plugins/community/splatoon/README.md">🦑 Splatoon</a><br><sup>by <a href="https://github.com/lowlighter">@lowlighter</a></sup>
<details><summary>Render example</summary>
<img alt="" width="400" src="https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.splatoon.svg" alt=""></img>
<img width="900" height="1" alt="">
</details>
</th>
</tr>
<tr>
<th><a href="source/plugins/community/stock/README.md">💹 Stock prices</a><br><sup>by <a href="https://github.com/lowlighter">@lowlighter</a></sup>
<details><summary>Render example</summary>
<img alt="" width="400" src="https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.stock.svg" alt=""></img>
<img width="900" height="1" alt="">
</details>
</th>
<th>
</th>
</tr>
<tr>
<th colspan="2" align="center">
@@ -527,6 +537,7 @@ Plugins provide additional content and lets you customize rendered metrics.
* **[Community plugins](/source/plugins/community/README.md)**
* [🧠 16personalities <sub>`16personalities`</sub>](/source/plugins/community/16personalities/README.md) by [@lowlighter](https://github.com/lowlighter)
* [♟️ Chess <sub>`chess`</sub>](/source/plugins/community/chess/README.md) by [@lowlighter](https://github.com/lowlighter)
* [🪙 Crypto <sub>`crypto`</sub>](/source/plugins/community/crypto/README.md) by [@dajneem23](https://github.com/dajneem23)
* [🥠 Fortune <sub>`fortune`</sub>](/source/plugins/community/fortune/README.md) by [@lowlighter](https://github.com/lowlighter)
* [💉 Nightscout <sub>`nightscout`</sub>](/source/plugins/community/nightscout/README.md) by [@legoandmars](https://github.com/legoandmars)
* [💩 PoopMap plugin <sub>`poopmap`</sub>](/source/plugins/community/poopmap/README.md) by [@matievisthekat](https://github.com/matievisthekat)

23
action.yml generated
View File

@@ -1322,6 +1322,29 @@ inputs:
description: Animation settings
default: <default-value>
# ====================================================================================
# 🪙 Crypto
plugin_crypto:
description: Enable crypto plugin
default: <default-value>
plugin_crypto_id:
description: Crypto id
default: <default-value>
plugin_crypto_vs_currency:
description: The target currency of market data (usd, eur, jpy, etc.)
default: <default-value>
plugin_crypto_days:
description: Data up to number of days ago (eg. 1,14,30,max)
default: <default-value>
plugin_crypto_precision:
description: The number of decimal places to use
default: <default-value>
# ====================================================================================
# 🥠 Fortune

3
settings.example.json generated
View File

@@ -191,6 +191,9 @@
"token": "Chess platform token",
"enabled": false, "//": "Enable chess plugin"
},
"crypto":{
"enabled": false, "//": "Enable crypto plugin"
},
"fortune":{
"enabled": false, "//": "Enable fortune plugin"
},

View File

@@ -52,6 +52,7 @@ Plugins provide additional content and lets you customize rendered metrics.
* **[Community plugins](/source/plugins/community/README.md)**
* [🧠 16personalities <sub>`16personalities`</sub>](/source/plugins/community/16personalities/README.md) by [@lowlighter](https://github.com/lowlighter)
* [♟️ Chess <sub>`chess`</sub>](/source/plugins/community/chess/README.md) by [@lowlighter](https://github.com/lowlighter)
* [🪙 Crypto <sub>`crypto`</sub>](/source/plugins/community/crypto/README.md) by [@dajneem23](https://github.com/dajneem23)
* [🥠 Fortune <sub>`fortune`</sub>](/source/plugins/community/fortune/README.md) by [@lowlighter](https://github.com/lowlighter)
* [💉 Nightscout <sub>`nightscout`</sub>](/source/plugins/community/nightscout/README.md) by [@legoandmars](https://github.com/legoandmars)
* [💩 PoopMap plugin <sub>`poopmap`</sub>](/source/plugins/community/poopmap/README.md) by [@matievisthekat](https://github.com/matievisthekat)

View File

@@ -16,44 +16,54 @@
<img width="900" height="1" alt="">
</td>
</tr> <tr>
<th><a href="/source/plugins/community/crypto/README.md">🪙 Crypto</a><br><sup>by <a href="https://github.com/dajneem23">@dajneem23</a></sup></th>
<th><a href="/source/plugins/community/fortune/README.md">🥠 Fortune</a><br><sup>by <a href="https://github.com/lowlighter">@lowlighter</a></sup></th>
<th><a href="/source/plugins/community/nightscout/README.md">💉 Nightscout</a><br><sup>by <a href="https://github.com/legoandmars">@legoandmars</a></sup></th>
</tr>
<tr>
<td align="center">
<img alt="" width="400" src="https://via.placeholder.com/468x60?text=No%20preview%20available" alt=""></img>
<img width="900" height="1" alt="">
</td>
<td align="center">
<img alt="" width="400" src="https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.fortune.svg" alt=""></img>
<img width="900" height="1" alt="">
</td>
</tr> <tr>
<th><a href="/source/plugins/community/nightscout/README.md">💉 Nightscout</a><br><sup>by <a href="https://github.com/legoandmars">@legoandmars</a></sup></th>
<th><a href="/source/plugins/community/poopmap/README.md">💩 PoopMap plugin</a><br><sup>by <a href="https://github.com/matievisthekat">@matievisthekat</a></sup></th>
</tr>
<tr>
<td align="center">
<img alt="" width="400" src="https://github.com/legoandmars/legoandmars/blob/master/metrics.plugin.nightscout.svg" alt=""></img>
<img width="900" height="1" alt="">
</td>
</tr> <tr>
<th><a href="/source/plugins/community/poopmap/README.md">💩 PoopMap plugin</a><br><sup>by <a href="https://github.com/matievisthekat">@matievisthekat</a></sup></th>
<th><a href="/source/plugins/community/screenshot/README.md">📸 Website screenshot</a><br><sup>by <a href="https://github.com/lowlighter">@lowlighter</a></sup></th>
</tr>
<tr>
<td align="center">
<img alt="" width="400" src="https://github.com/matievisthekat/matievisthekat/blob/master/metrics.plugin.poopmap.svg" alt=""></img>
<img width="900" height="1" alt="">
</td>
</tr> <tr>
<th><a href="/source/plugins/community/screenshot/README.md">📸 Website screenshot</a><br><sup>by <a href="https://github.com/lowlighter">@lowlighter</a></sup></th>
<th><a href="/source/plugins/community/splatoon/README.md">🦑 Splatoon</a><br><sup>by <a href="https://github.com/lowlighter">@lowlighter</a></sup></th>
</tr>
<tr>
<td align="center">
<img alt="" width="400" src="https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.screenshot.svg" alt=""></img>
<img width="900" height="1" alt="">
</td>
</tr> <tr>
<th><a href="/source/plugins/community/splatoon/README.md">🦑 Splatoon</a><br><sup>by <a href="https://github.com/lowlighter">@lowlighter</a></sup></th>
<th><a href="/source/plugins/community/stock/README.md">💹 Stock prices</a><br><sup>by <a href="https://github.com/lowlighter">@lowlighter</a></sup></th>
</tr>
<tr>
<td align="center">
<img alt="" width="400" src="https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.splatoon.svg" alt=""></img>
<img width="900" height="1" alt="">
</td>
</tr> <tr>
<th><a href="/source/plugins/community/stock/README.md">💹 Stock prices</a><br><sup>by <a href="https://github.com/lowlighter">@lowlighter</a></sup></th>
<th></th>
</tr>
<tr>
<td align="center">
<img alt="" width="400" src="https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.stock.svg" alt=""></img>
<img width="900" height="1" alt="">
</td>
<td align="center"><img width="900" height="1" alt=""></td>
</tr>
</table>

View File

@@ -0,0 +1,100 @@
<!-- Header -->
<table>
<tr><td colspan="2"><a href="/README.md#-plugins">← Back to plugins index</a></td></tr>
<tr><th colspan="2"><h3>🪙 Crypto</h3></th></tr>
<tr><td colspan="2" align="center">
<p>This plugin generates an SVG image containing crypto metrics from a given address. It uses the CoinGecko API to fetch crypto prices.</p>
<p>For more information, check the <a href="https://www.coingecko.com/vi/api/documentation">CoinGecko API documentation</a>.</p>
</td></tr>
<tr><th>Authors</th><td><a href="https://github.com/dajneem23">@dajneem23</a></td></tr>
<tr>
<th rowspan="3">Supported Features<br><sub><a href="metadata.yml">→ Full specification</a></sub></th>
<td>
<ul>
<li><a href="/source/templates/classic/README.md"><code>📗 Classic template</code></a></li>
<li><a href="/source/templates/repository/README.md"><code>📘 Repository template</code></a></li>
</ul>
</td>
</tr>
<tr>
<td>
<ul>
<li><code>👤 Users</code></li>
<li><code>👥 Organizations</code></li>
<li><code>📓 Repositories</code></li>
</ul>
</td>
</tr>
<tr>
<td><code>🗝️ plugin_crypto</code></td>
</tr>
<tr>
<td colspan="2" align="center">
<img src="https://via.placeholder.com/468x60?text=No%20preview%20available" alt=""></img>
<img width="900" height="1" alt="">
</td>
</tr>
</table>
<!-- /Header -->
## ➡️ Available Options
<!-- Options -->
<table>
<tr>
<td align="center" nowrap="nowrap">Option</td><td align="center" nowrap="nowrap">Description</td>
</tr>
<tr>
<td nowrap="nowrap"><h4><code>plugin_crypto</code></h4></td>
<td rowspan="2"><p>Enable crypto plugin</p><img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">Type: <code>boolean</code><br>Default: <code>no</code><br></td>
</tr>
<tr>
<td nowrap="nowrap"><h4><code>plugin_crypto_id</code></h4></td>
<td rowspan="2"><p>Crypto id (from Coingecko)</p><img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">Type: <code>string</code><br>Default: ""<br>Example: bitcoin<br></td>
</tr>
<tr>
<td nowrap="nowrap"><h4><code>plugin_crypto_vs_currency</code></h4></td>
<td rowspan="2"><p>The target currency of market data (usd, eur, jpy, etc.)</p><img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">Type: <code>string</code><br>Default: "usd"<br>Example: "usd"<br></td>
</tr>
<tr>
<td nowrap="nowrap"><h4><code>plugin_crypto_days</code></h4></td>
<td rowspan="2"><p>Data up to number of days ago (eg. 1,14,30,max)</p><img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">Type: <code>string</code><br>Default: "1"<br>Example: 1<br></td>
</tr>
<tr>
<td nowrap="nowrap"><h4><code>plugin_crypto_precision</code></h4></td>
<td rowspan="2"><p>The number of decimal places to use</p><img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">Type: <code>number</code><br>Default: 2<br>Example: 2<br></td>
</tr>
</table>
<!-- /Options -->
<!--examples-->
```yaml
name: Crypto Metrics
uses: lowlighter/metrics@latest
with:
filename: metrics.plugin.crypto.svg
token: NOT_NEEDED
base: ""
plugin_crypto: yes
plugin_crypto_id: bitcoin
plugin_crypto_vs_currency: usd
plugin_crypto_days: 1
plugin_crypto_precision: 2
```
<!--/examples-->

View File

@@ -0,0 +1,15 @@
- name: Crypto Metrics
uses: lowlighter/metrics@latest
with:
filename: metrics.plugin.crypto.svg
token: NOT_NEEDED
base: ""
plugin_crypto: yes
plugin_crypto_id: bitcoin
plugin_crypto_vs_currency: usd
plugin_crypto_days: 1
plugin_crypto_precision: 2
prod:
skip: true
test:
skip: true

View File

@@ -0,0 +1,69 @@
//Setup
export default async function({login, q, imports, data, account}, {enabled = false, extras = false} = {}) {
//Plugin execution
try {
//Check if plugin is enabled and requirements are met
if ((!q.crypto) || (!imports.metadata.plugins.crypto.enabled(enabled, {extras})))
return null
//Load inputs
let {id, days, vs_currency, precision} = imports.metadata.plugins.crypto.inputs({data, account, q})
if (!id)
throw {error: {message: "Crypto currency id is not set"}}
console.debug(`metrics/compute/${login}/plugins > crypto > querying api for crypto`)
const {
data: coin,
} = await imports.axios.get(`https://api.coingecko.com/api/v3/coins/${id}`, {
params: {
market_data: true,
},
})
if (!coin)
throw {error: {message: "Crypto currency not found"}}
const {
data: {prices},
} = await imports.axios.get(`https://api.coingecko.com/api/v3/coins/${id}/market_chart`, {
params: {
vs_currency,
days,
precision,
},
})
const chart = imports.Graph.timeline(
prices.map((y, _) => ({x: new Date(y[0]), y: y[1]})),
{
low: Math.min(...prices.map((y, _) => y[1])),
high: Math.max(...prices.map((y, _) => y[1])),
points: false,
text: false,
width: 480 * (1 + data.large),
height: 200,
},
)
//Results
return {
chart,
id,
precision,
days: {"1": "Today", "14": "2 Weeks", "30": "1 Month", max: "All-time"}[days],
symbol: coin.symbol,
name: coin.name,
current_price: coin.market_data.current_price[vs_currency],
price_change_percentage_24h: coin.market_data.price_change_percentage_24h,
vs_currency,
logo: coin.image.small,
}
}
//Handle errors
catch (error) {
throw imports.format.error(error)
}
}

View File

@@ -0,0 +1,52 @@
name: 🪙 Crypto
category: community
description: |
Generates a SVG image containing crypto metrics from a given address.
This plugin using coingecko API to fetch crypto prices.
check https://www.coingecko.com/vi/api/documentation for more information.
examples:
default: https://via.placeholder.com/468x60?text=No%20preview%20available
authors:
- dajneem23
supports:
- user
- organization
- repository
scopes: []
inputs:
plugin_crypto:
description: |
Enable crypto plugin
type: boolean
default: no
plugin_crypto_id:
description: |
Crypto id
type: string
default: ""
example: bitcoin
plugin_crypto_vs_currency:
description: |
The target currency of market data (usd, eur, jpy, etc.)
type: string
default: "usd"
example: "usd"
plugin_crypto_days:
description: |
Data up to number of days ago (eg. 1,14,30,max)
type: string
default: "1"
example: 1
plugin_crypto_precision:
description: |
The number of decimal places to use
type: number
default: 2
example: 2

View File

@@ -4,6 +4,7 @@ import os from "os"
import paths from "path"
import git from "simple-git"
import { filters } from "../../../app/metrics/utils.mjs"
import core from "@actions/core"
/**Analyzer */
export class Analyzer {
@@ -86,13 +87,19 @@ export class Analyzer {
/**Clone a repository */
async clone(repository) {
const {repo, branch, path} = this.parse(repository)
let url = /^https?:\/\//.test(repo) ? repo : `https://github.com/${repo}`
let token
if (process.env.GITHUB_ACTIONS) {
token = core.getInput("token")
}
let url = /^https?:\/\//.test(repo) ? repo : `https://${token}@github.com/${repo}`
try {
this.debug(`cloning ${url} to ${path}`)
this.debug(`cloning https://github.com/${repo} to ${path}`)
await fs.rm(path, {recursive: true, force: true})
await fs.mkdir(path, {recursive: true})
await git(path).clone(url, ".", ["--single-branch"]).status()
this.debug(`cloned ${url} to ${path}`)
this.debug(`cloned https://github.com/${repo} to ${path}`)
if (branch) {
this.debug(`switching to branch ${branch} for ${repo}`)
await git(path).branch(branch)
@@ -100,7 +107,7 @@ export class Analyzer {
return true
}
catch (error) {
this.debug(`failed to clone ${url} (${error})`)
this.debug(`failed to clone https://github.com/${repo} (${error})`)
this.clean(path)
return false
}
@@ -176,4 +183,4 @@ export class Analyzer {
debug(message) {
return console.debug(`metrics/compute/${this.login}/plugins > languages > ${this.constructor.name.replace(/([a-z])([A-Z])/, (_, a, b) => `${a} ${b.toLocaleLowerCase()}`).toLocaleLowerCase()} > ${message}`)
}
}
}

View File

@@ -7,7 +7,7 @@ This is also the default template.</p>
</td></tr>
<tr>
<th rowspan="3">Supported features<br><sub><a href="metadata.yml">→ Full specification</a></sub></th>
<td><a href="/source/plugins/achievements/README.md" title="🏆 Achievements">🏆</a> <a href="/source/plugins/activity/README.md" title="📰 Recent activity">📰</a> <a href="/source/plugins/anilist/README.md" title="🌸 Anilist watch list and reading list">🌸</a> <a href="/source/plugins/calendar/README.md" title="📆 Commit calendar">📆</a> <a href="/source/plugins/code/README.md" title="♐ Random code snippet">♐</a> <a href="/source/plugins/16personalities/README.md" title="🧠 16personalities">🧠</a> <a href="/source/plugins/chess/README.md" title="♟️ Chess">♟️</a> <a href="/source/plugins/fortune/README.md" title="🥠 Fortune">🥠</a> <a href="/source/plugins/nightscout/README.md" title="💉 Nightscout">💉</a> <a href="/source/plugins/poopmap/README.md" title="💩 PoopMap plugin">💩</a> <a href="/source/plugins/screenshot/README.md" title="📸 Website screenshot">📸</a> <a href="/source/plugins/splatoon/README.md" title="🦑 Splatoon">🦑</a> <a href="/source/plugins/stock/README.md" title="💹 Stock prices">💹</a> <a href="/source/plugins/discussions/README.md" title="💬 Discussions">💬</a> <a href="/source/plugins/followup/README.md" title="🎟️ Follow-up of issues and pull requests">🎟️</a> <a href="/source/plugins/gists/README.md" title="🎫 Gists">🎫</a> <a href="/source/plugins/habits/README.md" title="💡 Coding habits and activity">💡</a> <a href="/source/plugins/introduction/README.md" title="🙋 Introduction">🙋</a> <a href="/source/plugins/isocalendar/README.md" title="📅 Isometric commit calendar">📅</a> <a href="/source/plugins/languages/README.md" title="🈷️ Languages activity">🈷️</a> <a href="/source/plugins/leetcode/README.md" title="🗳️ Leetcode">🗳️</a> <a href="/source/plugins/lines/README.md" title="👨‍💻 Lines of code changed">👨‍💻</a> <a href="/source/plugins/music/README.md" title="🎼 Music activity and suggestions">🎼</a> <a href="/source/plugins/notable/README.md" title="🎩 Notable contributions">🎩</a> <a href="/source/plugins/pagespeed/README.md" title="⏱️ Google PageSpeed">⏱️</a> <a href="/source/plugins/people/README.md" title="🧑‍🤝‍🧑 People">🧑‍🤝‍🧑</a> <a href="/source/plugins/posts/README.md" title="✒️ Recent posts">✒️</a> <a href="/source/plugins/projects/README.md" title="🗂️ GitHub projects">🗂️</a> <a href="/source/plugins/reactions/README.md" title="🎭 Comment reactions">🎭</a> <a href="/source/plugins/repositories/README.md" title="📓 Featured repositories">📓</a> <a href="/source/plugins/rss/README.md" title="🗼 Rss feed">🗼</a> <a href="/source/plugins/skyline/README.md" title="🌇 GitHub Skyline">🌇</a> <a href="/source/plugins/sponsors/README.md" title="💕 GitHub Sponsors">💕</a> <a href="/source/plugins/sponsorships/README.md" title="💝 GitHub Sponsorships">💝</a> <a href="/source/plugins/stackoverflow/README.md" title="🗨️ Stack Overflow">🗨️</a> <a href="/source/plugins/stargazers/README.md" title="✨ Stargazers">✨</a> <a href="/source/plugins/starlists/README.md" title="💫 Star lists">💫</a> <a href="/source/plugins/stars/README.md" title="🌟 Recently starred repositories">🌟</a> <a href="/source/plugins/steam/README.md" title="🕹️ Steam">🕹️</a> <a href="/source/plugins/support/README.md" title="💭 GitHub Community Support">💭</a> <a href="/source/plugins/topics/README.md" title="📌 Starred topics">📌</a> <a href="/source/plugins/traffic/README.md" title="🧮 Repositories traffic">🧮</a> <a href="/source/plugins/tweets/README.md" title="🐤 Latest tweets">🐤</a> <a href="/source/plugins/wakatime/README.md" title="⏰ WakaTime">⏰</a></td>
<td><a href="/source/plugins/achievements/README.md" title="🏆 Achievements">🏆</a> <a href="/source/plugins/activity/README.md" title="📰 Recent activity">📰</a> <a href="/source/plugins/anilist/README.md" title="🌸 Anilist watch list and reading list">🌸</a> <a href="/source/plugins/calendar/README.md" title="📆 Commit calendar">📆</a> <a href="/source/plugins/code/README.md" title="♐ Random code snippet">♐</a> <a href="/source/plugins/16personalities/README.md" title="🧠 16personalities">🧠</a> <a href="/source/plugins/chess/README.md" title="♟️ Chess">♟️</a> <a href="/source/plugins/crypto/README.md" title="🪙 Crypto">🪙</a> <a href="/source/plugins/fortune/README.md" title="🥠 Fortune">🥠</a> <a href="/source/plugins/nightscout/README.md" title="💉 Nightscout">💉</a> <a href="/source/plugins/poopmap/README.md" title="💩 PoopMap plugin">💩</a> <a href="/source/plugins/screenshot/README.md" title="📸 Website screenshot">📸</a> <a href="/source/plugins/splatoon/README.md" title="🦑 Splatoon">🦑</a> <a href="/source/plugins/stock/README.md" title="💹 Stock prices">💹</a> <a href="/source/plugins/discussions/README.md" title="💬 Discussions">💬</a> <a href="/source/plugins/followup/README.md" title="🎟️ Follow-up of issues and pull requests">🎟️</a> <a href="/source/plugins/gists/README.md" title="🎫 Gists">🎫</a> <a href="/source/plugins/habits/README.md" title="💡 Coding habits and activity">💡</a> <a href="/source/plugins/introduction/README.md" title="🙋 Introduction">🙋</a> <a href="/source/plugins/isocalendar/README.md" title="📅 Isometric commit calendar">📅</a> <a href="/source/plugins/languages/README.md" title="🈷️ Languages activity">🈷️</a> <a href="/source/plugins/leetcode/README.md" title="🗳️ Leetcode">🗳️</a> <a href="/source/plugins/lines/README.md" title="👨‍💻 Lines of code changed">👨‍💻</a> <a href="/source/plugins/music/README.md" title="🎼 Music activity and suggestions">🎼</a> <a href="/source/plugins/notable/README.md" title="🎩 Notable contributions">🎩</a> <a href="/source/plugins/pagespeed/README.md" title="⏱️ Google PageSpeed">⏱️</a> <a href="/source/plugins/people/README.md" title="🧑‍🤝‍🧑 People">🧑‍🤝‍🧑</a> <a href="/source/plugins/posts/README.md" title="✒️ Recent posts">✒️</a> <a href="/source/plugins/projects/README.md" title="🗂️ GitHub projects">🗂️</a> <a href="/source/plugins/reactions/README.md" title="🎭 Comment reactions">🎭</a> <a href="/source/plugins/repositories/README.md" title="📓 Featured repositories">📓</a> <a href="/source/plugins/rss/README.md" title="🗼 Rss feed">🗼</a> <a href="/source/plugins/skyline/README.md" title="🌇 GitHub Skyline">🌇</a> <a href="/source/plugins/sponsors/README.md" title="💕 GitHub Sponsors">💕</a> <a href="/source/plugins/sponsorships/README.md" title="💝 GitHub Sponsorships">💝</a> <a href="/source/plugins/stackoverflow/README.md" title="🗨️ Stack Overflow">🗨️</a> <a href="/source/plugins/stargazers/README.md" title="✨ Stargazers">✨</a> <a href="/source/plugins/starlists/README.md" title="💫 Star lists">💫</a> <a href="/source/plugins/stars/README.md" title="🌟 Recently starred repositories">🌟</a> <a href="/source/plugins/steam/README.md" title="🕹️ Steam">🕹️</a> <a href="/source/plugins/support/README.md" title="💭 GitHub Community Support">💭</a> <a href="/source/plugins/topics/README.md" title="📌 Starred topics">📌</a> <a href="/source/plugins/traffic/README.md" title="🧮 Repositories traffic">🧮</a> <a href="/source/plugins/tweets/README.md" title="🐤 Latest tweets">🐤</a> <a href="/source/plugins/wakatime/README.md" title="⏰ WakaTime">⏰</a></td>
</tr>
<tr>
<td><code>👤 Users</code> <code>👥 Organizations</code></td>

View File

@@ -33,6 +33,7 @@
"support",
"stackoverflow",
"leetcode",
"crypto",
"stock",
"achievements",
"screenshot",

View File

@@ -0,0 +1,68 @@
<% if (plugins.crypto) { %>
<section>
<h2 class="field">
<img width="20" src="<%= plugins.crypto.logo %>" />
<%= plugins.crypto.symbol ? `${plugins.crypto.symbol?.toUpperCase()}` : "" %>
</h2>
<% if (plugins.crypto.error) { %>
<div class="row fill-width">
<section>
<div class="field error">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
<path
fill-rule="evenodd"
d="M2.343 13.657A8 8 0 1113.657 2.343 8 8 0 012.343 13.657zM6.03 4.97a.75.75 0 00-1.06 1.06L6.94 8 4.97 9.97a.75.75 0 101.06 1.06L8 9.06l1.97 1.97a.75.75 0 101.06-1.06L9.06 8l1.97-1.97a.75.75 0 10-1.06-1.06L8 6.94 6.03 4.97z"
></path>
</svg>
<%= plugins.crypto.error.message %>
</div>
</section>
</div>
<% } else { %>
<div class="row">
<section>
<div class="field">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
<path
fill-rule="evenodd"
d="M6 2a.75.75 0 01.696.471L10 10.731l1.304-3.26A.75.75 0 0112 7h3.25a.75.75 0 010 1.5h-2.742l-1.812 4.528a.75.75 0 01-1.392 0L6 4.77 4.696 8.03A.75.75 0 014 8.5H.75a.75.75 0 010-1.5h2.742l1.812-4.529A.75.75 0 016 2z"
></path>
</svg>
<%= `${plugins.crypto.current_price.toFixed(plugins.crypto.precision || 2) } ${plugins.crypto.vs_currency?.toUpperCase()}` %>
</div>
</section>
<section>
<div class="field">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
<path
fill-rule="evenodd"
d="M4.75 0a.75.75 0 01.75.75V2h5V.75a.75.75 0 011.5 0V2h1.25c.966 0 1.75.784 1.75 1.75v10.5A1.75 1.75 0 0113.25 16H2.75A1.75 1.75 0 011 14.25V3.75C1 2.784 1.784 2 2.75 2H4V.75A.75.75 0 014.75 0zm0 3.5h8.5a.25.25 0 01.25.25V6h-11V3.75a.25.25 0 01.25-.25h2zm-2.25 4v6.75c0 .138.112.25.25.25h10.5a.25.25 0 00.25-.25V7.5h-11z"
></path>
</svg>
<%= plugins.crypto.days %>
</div>
</section>
<section>
<div class="field">
<% if (plugins.crypto.price_change_percentage_24h > 0) { %>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
<path
fill-rule="evenodd"
d="M3.47 7.78a.75.75 0 010-1.06l4.25-4.25a.75.75 0 011.06 0l4.25 4.25a.75.75 0 01-1.06 1.06L9 4.81v7.44a.75.75 0 01-1.5 0V4.81L4.53 7.78a.75.75 0 01-1.06 0z"
></path>
</svg>
<% } else { %>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
<path
fill-rule="evenodd"
d="M13.03 8.22a.75.75 0 010 1.06l-4.25 4.25a.75.75 0 01-1.06 0L3.47 9.28a.75.75 0 011.06-1.06l2.97 2.97V3.75a.75.75 0 011.5 0v7.44l2.97-2.97a.75.75 0 011.06 0z"
></path>
</svg>
<% } %> <%= plugins.crypto.price_change_percentage_24h ?plugins.crypto.price_change_percentage_24h.toFixed(2) : 0 %>%
</div>
</section>
</div>
<div class="crypto-chart"><%- plugins.crypto.chart %></div>
<% } %>
</section>
<% } %>

View File

@@ -6,7 +6,7 @@
</td></tr>
<tr>
<th rowspan="3">Supported features<br><sub><a href="metadata.yml">→ Full specification</a></sub></th>
<td><a href="/source/plugins/activity/README.md" title="📰 Recent activity">📰</a> <a href="/source/plugins/screenshot/README.md" title="📸 Website screenshot">📸</a> <a href="/source/plugins/stock/README.md" title="💹 Stock prices">💹</a> <a href="/source/plugins/contributors/README.md" title="🏅 Repository contributors">🏅</a> <a href="/source/plugins/followup/README.md" title="🎟️ Follow-up of issues and pull requests">🎟️</a> <a href="/source/plugins/introduction/README.md" title="🙋 Introduction">🙋</a> <a href="/source/plugins/languages/README.md" title="🈷️ Languages activity">🈷️</a> <a href="/source/plugins/licenses/README.md" title="📜 Repository licenses">📜</a> <a href="/source/plugins/lines/README.md" title="👨‍💻 Lines of code changed">👨‍💻</a> <a href="/source/plugins/pagespeed/README.md" title="⏱️ Google PageSpeed">⏱️</a> <a href="/source/plugins/people/README.md" title="🧑‍🤝‍🧑 People">🧑‍🤝‍🧑</a> <a href="/source/plugins/posts/README.md" title="✒️ Recent posts">✒️</a> <a href="/source/plugins/projects/README.md" title="🗂️ GitHub projects">🗂️</a> <a href="/source/plugins/rss/README.md" title="🗼 Rss feed">🗼</a> <a href="/source/plugins/sponsors/README.md" title="💕 GitHub Sponsors">💕</a> <a href="/source/plugins/stargazers/README.md" title="✨ Stargazers">✨</a> <a href="/source/plugins/traffic/README.md" title="🧮 Repositories traffic">🧮</a></td>
<td><a href="/source/plugins/activity/README.md" title="📰 Recent activity">📰</a> <a href="/source/plugins/crypto/README.md" title="🪙 Crypto">🪙</a> <a href="/source/plugins/screenshot/README.md" title="📸 Website screenshot">📸</a> <a href="/source/plugins/stock/README.md" title="💹 Stock prices">💹</a> <a href="/source/plugins/contributors/README.md" title="🏅 Repository contributors">🏅</a> <a href="/source/plugins/followup/README.md" title="🎟️ Follow-up of issues and pull requests">🎟️</a> <a href="/source/plugins/introduction/README.md" title="🙋 Introduction">🙋</a> <a href="/source/plugins/languages/README.md" title="🈷️ Languages activity">🈷️</a> <a href="/source/plugins/licenses/README.md" title="📜 Repository licenses">📜</a> <a href="/source/plugins/lines/README.md" title="👨‍💻 Lines of code changed">👨‍💻</a> <a href="/source/plugins/pagespeed/README.md" title="⏱️ Google PageSpeed">⏱️</a> <a href="/source/plugins/people/README.md" title="🧑‍🤝‍🧑 People">🧑‍🤝‍🧑</a> <a href="/source/plugins/posts/README.md" title="✒️ Recent posts">✒️</a> <a href="/source/plugins/projects/README.md" title="🗂️ GitHub projects">🗂️</a> <a href="/source/plugins/rss/README.md" title="🗼 Rss feed">🗼</a> <a href="/source/plugins/sponsors/README.md" title="💕 GitHub Sponsors">💕</a> <a href="/source/plugins/stargazers/README.md" title="✨ Stargazers">✨</a> <a href="/source/plugins/traffic/README.md" title="🧮 Repositories traffic">🧮</a></td>
</tr>
<tr>
<td><code>📓 Repositories</code></td>

View File

@@ -12,6 +12,7 @@
"rss",
"screenshot",
"stock",
"crypto",
"contributors",
"sponsors",
"licenses"

View File

@@ -0,0 +1,68 @@
<% if (plugins.crypto) { %>
<section>
<h2 class="field">
<img width="20" src="<%= plugins.crypto.logo %>" />
<%= plugins.crypto.symbol ? `${plugins.crypto.symbol?.toUpperCase()}` : "" %>
</h2>
<% if (plugins.crypto.error) { %>
<div class="row fill-width">
<section>
<div class="field error">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
<path
fill-rule="evenodd"
d="M2.343 13.657A8 8 0 1113.657 2.343 8 8 0 012.343 13.657zM6.03 4.97a.75.75 0 00-1.06 1.06L6.94 8 4.97 9.97a.75.75 0 101.06 1.06L8 9.06l1.97 1.97a.75.75 0 101.06-1.06L9.06 8l1.97-1.97a.75.75 0 10-1.06-1.06L8 6.94 6.03 4.97z"
></path>
</svg>
<%= plugins.crypto.error.message %>
</div>
</section>
</div>
<% } else { %>
<div class="row">
<section>
<div class="field">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
<path
fill-rule="evenodd"
d="M6 2a.75.75 0 01.696.471L10 10.731l1.304-3.26A.75.75 0 0112 7h3.25a.75.75 0 010 1.5h-2.742l-1.812 4.528a.75.75 0 01-1.392 0L6 4.77 4.696 8.03A.75.75 0 014 8.5H.75a.75.75 0 010-1.5h2.742l1.812-4.529A.75.75 0 016 2z"
></path>
</svg>
<%= `${plugins.crypto.current_price.toFixed(plugins.crypto.precision || 2) } ${plugins.crypto.vs_currency?.toUpperCase()}` %>
</div>
</section>
<section>
<div class="field">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
<path
fill-rule="evenodd"
d="M4.75 0a.75.75 0 01.75.75V2h5V.75a.75.75 0 011.5 0V2h1.25c.966 0 1.75.784 1.75 1.75v10.5A1.75 1.75 0 0113.25 16H2.75A1.75 1.75 0 011 14.25V3.75C1 2.784 1.784 2 2.75 2H4V.75A.75.75 0 014.75 0zm0 3.5h8.5a.25.25 0 01.25.25V6h-11V3.75a.25.25 0 01.25-.25h2zm-2.25 4v6.75c0 .138.112.25.25.25h10.5a.25.25 0 00.25-.25V7.5h-11z"
></path>
</svg>
<%= plugins.crypto.days %>
</div>
</section>
<section>
<div class="field">
<% if (plugins.crypto.price_change_percentage_24h > 0) { %>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
<path
fill-rule="evenodd"
d="M3.47 7.78a.75.75 0 010-1.06l4.25-4.25a.75.75 0 011.06 0l4.25 4.25a.75.75 0 01-1.06 1.06L9 4.81v7.44a.75.75 0 01-1.5 0V4.81L4.53 7.78a.75.75 0 01-1.06 0z"
></path>
</svg>
<% } else { %>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
<path
fill-rule="evenodd"
d="M13.03 8.22a.75.75 0 010 1.06l-4.25 4.25a.75.75 0 01-1.06 0L3.47 9.28a.75.75 0 011.06-1.06l2.97 2.97V3.75a.75.75 0 011.5 0v7.44l2.97-2.97a.75.75 0 011.06 0z"
></path>
</svg>
<% } %> <%= plugins.crypto.price_change_percentage_24h ?plugins.crypto.price_change_percentage_24h.toFixed(2) : 0 %>%
</div>
</section>
</div>
<div class="crypto-chart"><%- plugins.crypto.chart %></div>
<% } %>
</section>
<% } %>

1
tests/cases/crypto.plugin.yml generated Normal file
View File

@@ -0,0 +1 @@
[]