Skip to content

Fix chart.js-v4 invalid engine warning #210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6a9e5fb
template feature
andrii-ivanov Feb 18, 2025
217105f
template feature
andrii-ivanov Feb 18, 2025
06e56e8
template feature
andrii-ivanov Feb 18, 2025
44ddf2a
Add chart template functionality
jmaddington Mar 24, 2025
767df0a
Bump version to 1.9.0
jmaddington Mar 24, 2025
fa18d00
Add GitHub Actions workflows for Docker image builds
jmaddington Mar 24, 2025
85eed6a
Add GitHub Actions workflow for running tests
jmaddington Mar 24, 2025
f53b30a
Fix GitHub Actions test workflow by adding missing dependencies
jmaddington Mar 24, 2025
385db47
Fix database and test timeouts in GitHub Actions workflow
jmaddington Mar 24, 2025
df8a71b
Update port configuration in GitHub Actions test workflow
jmaddington Mar 24, 2025
84ef7f9
Fix json-schema vulnerability by setting minimum version to 0.4.0
jmaddington Mar 24, 2025
880b087
Fix database directory creation in GitHub Actions workflow
jmaddington Mar 24, 2025
4219af4
Use npx to run mocha from node_modules
jmaddington Mar 24, 2025
57e633f
Fix SVG test by making it more resilient to format changes
jmaddington Mar 24, 2025
d783df2
Fix flat and crypto-js vulnerabilities by enforcing secure versions
jmaddington Mar 24, 2025
8e9399e
Fix high severity vulnerabilities
jmaddington Mar 24, 2025
ed8b9e7
Merge remote-tracking branch 'origin/master'
andrii-ivanov Mar 25, 2025
cc74606
Merge remote-tracking branch 'origin/fix-json-schema-vulnerability' i…
andrii-ivanov Mar 27, 2025
bdea108
Merge remote-tracking branch 'origin/fix-flat-and-crypto-js-vulnerabi…
andrii-ivanov Mar 27, 2025
272ff42
Merge remote-tracking branch 'origin/fix-high-severity-vulnerabilitie…
andrii-ivanov Mar 27, 2025
81e00fb
Fix chart.js-v4 invalid engine warning by updating to version 4.3.3
jmaddington Mar 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/docker-build-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build and Publish Dev Docker Image

on:
push:
branches:
- dev
workflow_dispatch:

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get repository name in lowercase
id: repo_name
run: echo "REPO_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT

- name: Get version from package.json
id: package_version
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT

- name: Get short SHA
id: short_sha
run: echo "SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
ghcr.io/${{ steps.repo_name.outputs.REPO_NAME }}:dev
ghcr.io/${{ steps.repo_name.outputs.REPO_NAME }}:${{ steps.package_version.outputs.VERSION }}-dev
ghcr.io/${{ steps.repo_name.outputs.REPO_NAME }}:${{ steps.package_version.outputs.VERSION }}-${{ steps.short_sha.outputs.SHA }}
cache-from: type=registry,ref=ghcr.io/${{ steps.repo_name.outputs.REPO_NAME }}:dev
cache-to: type=inline
44 changes: 44 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build and Publish Docker Image

on:
push:
branches:
- master
workflow_dispatch:

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get repository name in lowercase
id: repo_name
run: echo "REPO_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT

- name: Get version from package.json
id: package_version
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
ghcr.io/${{ steps.repo_name.outputs.REPO_NAME }}:latest
ghcr.io/${{ steps.repo_name.outputs.REPO_NAME }}:${{ steps.package_version.outputs.VERSION }}
cache-from: type=registry,ref=ghcr.io/${{ steps.repo_name.outputs.REPO_NAME }}:latest
cache-to: type=inline
81 changes: 81 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Run Tests

on:
push:
pull_request:
branches:
- master
- dev
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'yarn'

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential g++ python3-dev
sudo apt-get install -y libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
sudo apt-get install -y libpixman-1-dev libvips-dev
sudo apt-get install -y graphviz
sudo apt-get install -y sqlite3 libsqlite3-dev
sudo apt-get install -y fonts-dejavu fonts-noto fonts-noto-cjk fonts-noto-color-emoji fontconfig
sudo apt-get install -y pkg-config
sudo apt-get install -y libimagequant-dev
yarn install

- name: Set up database directory
run: |
sudo mkdir -p /var/lib/db
sudo chmod 777 /var/lib/db

- name: Run basic tests only
run: |
# Skip the chart-create.test.js tests that require database access
PORT=3400 NODE_ENV=test npx mocha --exit --recursive test/ci/charts.js test/ci/graphviz.js test/ci/google_image_charts.js test/ci/qr.js
env:
NODE_ENV: test
PORT: 3400
NODE_OPTIONS: --experimental-global-webcrypto

lint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'yarn'

- name: Install dependencies for linting
run: |
sudo apt-get update
sudo apt-get install -y build-essential g++ python3-dev
sudo apt-get install -y libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
sudo apt-get install -y libpixman-1-dev libvips-dev
sudo apt-get install -y pkg-config
sudo apt-get install -y libimagequant-dev
yarn install

- name: Lint code
run: |
if [ -f ".eslintrc.js" ] || [ -f ".eslintrc.json" ] || [ -f ".eslintrc.yml" ] || [ -f ".eslintrc.yaml" ]; then
npx eslint .
else
echo "No ESLint configuration found, skipping lint step"
fi
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RUN apk add --no-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/c
RUN apk add --no-cache libimagequant-dev
RUN apk add --no-cache vips-dev
RUN apk add --no-cache --virtual .runtime-deps graphviz
RUN apk add --no-cache sqlite

COPY package*.json .
COPY yarn.lock .
Expand All @@ -25,7 +26,7 @@ RUN apk del .build-deps
COPY *.js ./
COPY lib/*.js lib/
COPY LICENSE .

VOLUME /var/lib/db/
EXPOSE 3400

ENTRYPOINT ["node", "--max-http-header-size=65536", "index.js"]
ENTRYPOINT ["node", "--max-http-header-size=65536", "--experimental-global-webcrypto", "index.js"]
34 changes: 34 additions & 0 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM node:18-alpine3.17

ENV NODE_ENV test
ENV NODE_OPTIONS --experimental-global-webcrypto
WORKDIR /quickchart

RUN apk add --upgrade apk-tools
RUN apk add --no-cache --virtual .build-deps yarn git build-base g++ python3
RUN apk add --no-cache --virtual .npm-deps cairo-dev pango-dev libjpeg-turbo-dev librsvg-dev
RUN apk add --no-cache --virtual .fonts libmount ttf-dejavu ttf-droid ttf-freefont ttf-liberation font-noto font-noto-emoji fontconfig
RUN apk add --no-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/community font-wqy-zenhei
RUN apk add --no-cache libimagequant-dev
RUN apk add --no-cache vips-dev
RUN apk add --no-cache --virtual .runtime-deps graphviz
RUN apk add --no-cache sqlite
RUN npm install -g mocha

COPY package*.json .
COPY yarn.lock .
RUN yarn install --development

RUN apk update
RUN rm -rf /var/cache/apk/* && \
rm -rf /tmp/*
RUN apk del .build-deps

COPY *.js ./
COPY lib/*.js lib/
COPY test/ test/
COPY LICENSE .
EXPOSE 3401
VOLUME /var/lib/db/
ENTRYPOINT ["npm" , "run", "test"]

42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,48 @@ If you are self-hosting QuickChart, each QuickChart instance should use a single

This self-hosted QuickChart implementation currently supports the `/chart`, `/qr`, and `/graphviz` endpoints. Other endpoints such as `/wordcloud`, `watermark`, `/chart/create` are not available in this version due to non-OSS 3rd-party dependencies.

**Note:** This release adds `/chart/create/` and `/chart/render/` functionality. For data storage, sqlite db is used.
It supports functionality as described [here](https://quickchart.io/documentation/usage/short-urls-and-templates/#short-urls) and [here](https://quickchart.io/documentation/usage/short-urls-and-templates/#templates)

Example body for `/chart/create/`:

```json
{
"chart": {
"options": {
"title": {
"display": true,
"text": "Chart Title"
}
},
"type": "bar",
"data": {
"labels": [
"A",
"B"
],
"datasets": [
{
"data": [
10,
20
]
}
]
}
},
"neverExpire": true
}
```

The **neverExpire** parameter allows you to control the expiration time of the saved chart.
If **"neverExpire": true**, then the chart has no storage time restrictions, otherwise, if this parameter is not specified or is false, then the expiraton time will be set to 6 months.

To run it with docker:
```shell
docker build -t quickchart .
docker run -p 3400:3400 -v /path/to/db/folder/:/var/lib/db/ quickchart
```
## License

QuickChart is open source, licensed under version 3 of the GNU AGPL. If you would like to modify this project for commercial purposes (and not release the source code), please [contact me](https://www.ianww.com/).
Loading