Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b7b3e6ace | ||
|
|
92f4de3970 | ||
|
|
c9644d3dfa | ||
|
|
01fa6d7aac | ||
|
|
b58af55b7d | ||
|
|
4e5805f8af | ||
|
|
743771147d | ||
|
|
8eddcbdbea | ||
|
|
6f0ace6560 | ||
|
|
835fdd6b84 | ||
|
|
e6034f3972 |
18
.github/workflows/main.yml
vendored
18
.github/workflows/main.yml
vendored
@@ -7,11 +7,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
cache: yarn
|
||||
node-version: 16
|
||||
node-version: 20
|
||||
- run: yarn install --frozen-lockfile
|
||||
|
||||
- run: npm run type
|
||||
@@ -23,7 +23,7 @@ jobs:
|
||||
test-action:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: update action.yml to use image from local Dockerfile
|
||||
run: |
|
||||
@@ -38,8 +38,6 @@ jobs:
|
||||
dist/github-contribution-grid-snake.svg
|
||||
dist/github-contribution-grid-snake-dark.svg?palette=github-dark
|
||||
dist/github-contribution-grid-snake.gif?color_snake=orange&color_dots=#bfd6f6,#8dbdff,#64a1f4,#4b91f1,#3c7dd9
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: ensure the generated file exists
|
||||
run: |
|
||||
@@ -58,11 +56,11 @@ jobs:
|
||||
test-action-svg-only:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
cache: yarn
|
||||
node-version: 16
|
||||
node-version: 20
|
||||
- run: yarn install --frozen-lockfile
|
||||
|
||||
- name: build svg-only action
|
||||
@@ -79,8 +77,6 @@ jobs:
|
||||
outputs: |
|
||||
dist/github-contribution-grid-snake.svg
|
||||
dist/github-contribution-grid-snake-dark.svg?palette=github-dark
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: ensure the generated file exists
|
||||
run: |
|
||||
@@ -98,11 +94,11 @@ jobs:
|
||||
deploy-ghpages:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
cache: yarn
|
||||
node-version: 16
|
||||
node-version: 20
|
||||
- run: yarn install --frozen-lockfile
|
||||
|
||||
- run: npm run build:demo
|
||||
|
||||
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: docker/setup-qemu-action@v2
|
||||
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
cache: yarn
|
||||
node-version: 16
|
||||
node-version: 20
|
||||
|
||||
- name: build svg-only action
|
||||
run: |
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM node:16-slim as builder
|
||||
FROM node:20-slim as builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@@ -18,12 +18,12 @@ RUN yarn build:action
|
||||
|
||||
|
||||
|
||||
FROM node:16-slim
|
||||
FROM node:20-slim
|
||||
|
||||
WORKDIR /action-release
|
||||
|
||||
RUN export YARN_CACHE_FOLDER="$(mktemp -d)" \
|
||||
&& yarn add canvas@2.10.2 gifsicle@5.3.0 --no-lockfile \
|
||||
&& yarn add canvas@2.11.2 gifsicle@5.3.0 --no-lockfile \
|
||||
&& rm -r "$YARN_CACHE_FOLDER"
|
||||
|
||||
COPY --from=builder /app/packages/action/dist/ /action-release/
|
||||
|
||||
10
README.md
10
README.md
@@ -55,14 +55,14 @@ Available as github action. It can automatically generate a new image each day.
|
||||
dist/github-snake-dark.svg?palette=github-dark
|
||||
dist/ocean.gif?color_snake=orange&color_dots=#bfd6f6,#8dbdff,#64a1f4,#4b91f1,#3c7dd9
|
||||
|
||||
env:
|
||||
# a github token is required to fetch the contribution calendar from github API
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
env:
|
||||
# a github token is required to fetch the contribution calendar from github API
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
[example with cron job](https://github.com/Platane/Platane/blob/master/.github/workflows/main.yml#L24-L29)
|
||||
[example with cron job](https://github.com/Platane/Platane/blob/master/.github/workflows/main.yml#L26-L35)
|
||||
|
||||
If you are only interested in generating a svg, consider using this faster action: `uses: Platane/snk/svg-only@v2`
|
||||
If you are only interested in generating a svg, consider using this faster action: `uses: Platane/snk/svg-only@v3`
|
||||
|
||||
**dark mode**
|
||||
|
||||
|
||||
@@ -4,12 +4,16 @@ author: "platane"
|
||||
|
||||
runs:
|
||||
using: docker
|
||||
image: docker://platane/snk@sha256:753878055e52fbbaf3148fdac4590e396f97581f1dc4c1f861701add7a1dc1b5
|
||||
image: docker://platane/snk@sha256:1c8a0b51a75ad8cf36b7defddd2187bdbb92bbbb5521a9e6cc5df795b00fc590
|
||||
|
||||
inputs:
|
||||
github_user_name:
|
||||
description: "github user name"
|
||||
required: true
|
||||
github_token:
|
||||
description: "github token used to fetch the contribution calendar. Default to the action token if empty."
|
||||
required: false
|
||||
default: ${{ github.token }}
|
||||
outputs:
|
||||
required: false
|
||||
default: null
|
||||
|
||||
12
package.json
12
package.json
@@ -1,17 +1,17 @@
|
||||
{
|
||||
"name": "snk",
|
||||
"description": "Generates a snake game from a github user contributions grid",
|
||||
"version": "3.0.0",
|
||||
"version": "3.2.0",
|
||||
"private": true,
|
||||
"repository": "github:platane/snk",
|
||||
"devDependencies": {
|
||||
"@sucrase/jest-plugin": "3.0.0",
|
||||
"@types/jest": "29.5.3",
|
||||
"@types/node": "16.18.38",
|
||||
"jest": "29.6.1",
|
||||
"@types/jest": "29.5.5",
|
||||
"@types/node": "20.6.3",
|
||||
"jest": "29.7.0",
|
||||
"prettier": "2.8.8",
|
||||
"sucrase": "3.33.0",
|
||||
"typescript": "5.1.6"
|
||||
"sucrase": "3.34.0",
|
||||
"typescript": "5.2.2"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/**"
|
||||
|
||||
@@ -12,7 +12,8 @@ import { parseOutputsOption } from "./outputsOptions";
|
||||
core.getInput("svg_out_path"),
|
||||
]
|
||||
);
|
||||
const githubToken = process.env.GITHUB_TOKEN!;
|
||||
const githubToken =
|
||||
process.env.GITHUB_TOKEN ?? core.getInput("github_token");
|
||||
|
||||
const { generateContributionSnake } = await import(
|
||||
"./generateContributionSnake"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "@snk/action",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@actions/core": "1.10.0",
|
||||
"@actions/core": "1.10.1",
|
||||
"@snk/gif-creator": "1.0.0",
|
||||
"@snk/github-user-contribution": "1.0.0",
|
||||
"@snk/solver": "1.0.0",
|
||||
@@ -10,7 +10,7 @@
|
||||
"@snk/types": "1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vercel/ncc": "0.36.1",
|
||||
"@vercel/ncc": "0.38.0",
|
||||
"dotenv": "16.3.1"
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
@@ -10,12 +10,13 @@
|
||||
"@snk/types": "1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"dotenv": "16.3.1",
|
||||
"@types/dat.gui": "0.7.10",
|
||||
"dat.gui": "0.7.9",
|
||||
"html-webpack-plugin": "5.5.3",
|
||||
"ts-loader": "9.4.4",
|
||||
"ts-node": "10.9.1",
|
||||
"webpack": "5.88.1",
|
||||
"webpack": "5.88.2",
|
||||
"webpack-cli": "5.1.4",
|
||||
"webpack-dev-server": "4.15.1"
|
||||
},
|
||||
|
||||
@@ -66,7 +66,7 @@ export const drawWorld = (
|
||||
};
|
||||
|
||||
export const drawLerpWorld = (
|
||||
ctx: CanvasRenderingContext2D,
|
||||
ctx: CanvasRenderingContext2D | CanvasRenderingContext2D,
|
||||
grid: Grid,
|
||||
cells: Point[] | null,
|
||||
snake0: Snake,
|
||||
|
||||
@@ -43,7 +43,7 @@ export const createGif = async (
|
||||
const { width, height } = getCanvasWorldSize(grid0, drawOptions);
|
||||
|
||||
const canvas = createCanvas(width, height);
|
||||
const ctx = canvas.getContext("2d")!;
|
||||
const ctx = canvas.getContext("2d") as any as CanvasRenderingContext2D;
|
||||
|
||||
const grid = copyGrid(grid0);
|
||||
const stack: Color[] = [];
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
"dependencies": {
|
||||
"@snk/draw": "1.0.0",
|
||||
"@snk/solver": "1.0.0",
|
||||
"canvas": "2.10.2",
|
||||
"canvas": "2.11.2",
|
||||
"gif-encoder-2": "1.0.5",
|
||||
"gifsicle": "5.3.0",
|
||||
"tmp": "0.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/gifsicle": "5.2.0",
|
||||
"@types/tmp": "0.2.3",
|
||||
"@vercel/ncc": "0.36.1"
|
||||
"@types/tmp": "0.2.4",
|
||||
"@vercel/ncc": "0.38.0"
|
||||
},
|
||||
"scripts": {
|
||||
"benchmark": "ncc run __tests__/benchmark.ts --quiet"
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { getGithubUserContribution } from "@snk/github-user-contribution";
|
||||
import { VercelRequest, VercelResponse } from "@vercel/node";
|
||||
import nodeFetch from "node-fetch";
|
||||
|
||||
(global as any).fetch = nodeFetch;
|
||||
|
||||
export default async (req: VercelRequest, res: VercelResponse) => {
|
||||
const { userName } = req.query;
|
||||
@@ -9,7 +12,7 @@ export default async (req: VercelRequest, res: VercelResponse) => {
|
||||
res.statusCode = 200;
|
||||
res.json(
|
||||
await getGithubUserContribution(userName as string, {
|
||||
githubToken: process.env.GITHUB!,
|
||||
githubToken: process.env.GITHUB_TOKEN!,
|
||||
})
|
||||
);
|
||||
} catch (err) {
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
"name": "@snk/github-user-contribution-service",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"node-fetch": "2.7.0",
|
||||
"@snk/github-user-contribution": "1.0.0",
|
||||
"@vercel/node": "2.15.5"
|
||||
"@vercel/node": "3.0.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node-fetch": "2.6.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,11 +8,6 @@ describe("getGithubUserContribution", () => {
|
||||
});
|
||||
|
||||
it("should resolve", async () => {
|
||||
console.log(
|
||||
"process.env.GITHUB_TOKEN",
|
||||
process.env.GITHUB_TOKEN?.replace(/\d/g, "x")
|
||||
);
|
||||
|
||||
await promise;
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import fetch from "node-fetch";
|
||||
|
||||
/**
|
||||
* get the contribution grid from a github user page
|
||||
*
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
{
|
||||
"name": "@snk/github-user-contribution",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"node-fetch": "2.6.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node-fetch": "2.6.4",
|
||||
"dotenv": "16.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,17 @@ description: "Generates a snake game from a github user contributions grid. Outp
|
||||
author: "platane"
|
||||
|
||||
runs:
|
||||
using: node16
|
||||
using: node20
|
||||
main: dist/index.js
|
||||
|
||||
inputs:
|
||||
github_user_name:
|
||||
description: "github user name"
|
||||
required: true
|
||||
github_token:
|
||||
description: "github token used to fetch the contribution calendar. Default to the action token if empty."
|
||||
required: false
|
||||
default: ${{ github.token }}
|
||||
outputs:
|
||||
required: false
|
||||
default: null
|
||||
|
||||
3982
svg-only/dist/197.index.js
vendored
3982
svg-only/dist/197.index.js
vendored
File diff suppressed because one or more lines are too long
6
svg-only/dist/407.index.js
vendored
6
svg-only/dist/407.index.js
vendored
@@ -14,11 +14,7 @@ __webpack_require__.d(__webpack_exports__, {
|
||||
"generateContributionSnake": () => (/* binding */ generateContributionSnake)
|
||||
});
|
||||
|
||||
// EXTERNAL MODULE: ../../node_modules/node-fetch/lib/index.js
|
||||
var lib = __webpack_require__(2197);
|
||||
var lib_default = /*#__PURE__*/__webpack_require__.n(lib);
|
||||
;// CONCATENATED MODULE: ../github-user-contribution/index.ts
|
||||
|
||||
/**
|
||||
* get the contribution grid from a github user page
|
||||
*
|
||||
@@ -55,7 +51,7 @@ const getGithubUserContribution = async (userName, o) => {
|
||||
}
|
||||
`;
|
||||
const variables = { login: userName };
|
||||
const res = await lib_default()("https://api.github.com/graphql", {
|
||||
const res = await fetch("https://api.github.com/graphql", {
|
||||
headers: {
|
||||
Authorization: `bearer ${o.githubToken}`,
|
||||
"Content-Type": "application/json",
|
||||
|
||||
30
svg-only/dist/index.js
vendored
30
svg-only/dist/index.js
vendored
@@ -558,7 +558,7 @@ class OidcClient {
|
||||
.catch(error => {
|
||||
throw new Error(`Failed to get ID Token. \n
|
||||
Error Code : ${error.statusCode}\n
|
||||
Error Message: ${error.result.message}`);
|
||||
Error Message: ${error.message}`);
|
||||
});
|
||||
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
|
||||
if (!id_token) {
|
||||
@@ -2784,14 +2784,6 @@ module.exports = require("path");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5477:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = require("punycode");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 2781:
|
||||
/***/ ((module) => {
|
||||
|
||||
@@ -2808,28 +2800,12 @@ module.exports = require("tls");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 7310:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = require("url");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3837:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = require("util");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9796:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = require("zlib");
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
||||
@@ -3098,8 +3074,8 @@ const parseEntry = (entry) => {
|
||||
core.getInput("gif_out_path"),
|
||||
core.getInput("svg_out_path"),
|
||||
]);
|
||||
const githubToken = process.env.GITHUB_TOKEN;
|
||||
const { generateContributionSnake } = await Promise.all(/* import() */[__nccwpck_require__.e(197), __nccwpck_require__.e(407)]).then(__nccwpck_require__.bind(__nccwpck_require__, 407));
|
||||
const githubToken = process.env.GITHUB_TOKEN ?? core.getInput("github_token");
|
||||
const { generateContributionSnake } = await __nccwpck_require__.e(/* import() */ 407).then(__nccwpck_require__.bind(__nccwpck_require__, 407));
|
||||
const results = await generateContributionSnake(userName, outputs, {
|
||||
githubToken,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user