Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
047c7191f3 | ||
|
|
10d162247f | ||
|
|
13f9f66ae0 | ||
|
|
7e80be60db | ||
|
|
16eb314428 | ||
|
|
72507d3b16 | ||
|
|
a7ffc4959e | ||
|
|
8271057335 | ||
|
|
6d9d6bd0f7 | ||
|
|
ae451ddb81 |
7
.github/workflows/deploy.yml
vendored
7
.github/workflows/deploy.yml
vendored
@@ -1,9 +1,12 @@
|
||||
name: deploy
|
||||
|
||||
on: [push]
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
test:
|
||||
deploy-demo:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
||||
15
.github/workflows/main.yml
vendored
15
.github/workflows/main.yml
vendored
@@ -7,7 +7,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- run: sudo apt-get install gifsicle graphicsmagick
|
||||
# - run: sudo apt-get install gifsicle graphicsmagick
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
@@ -15,6 +15,13 @@ jobs:
|
||||
|
||||
- uses: bahmutov/npm-install@v1
|
||||
|
||||
- run: yarn type
|
||||
- run: yarn lint
|
||||
- run: yarn test --ci
|
||||
# - run: yarn type
|
||||
# - run: yarn lint
|
||||
# - run: yarn test --ci
|
||||
# - run: yarn build:lib
|
||||
|
||||
- uses: actions/github-contribution-grid-snake@v1
|
||||
with:
|
||||
github_user_name: platane
|
||||
|
||||
- run: ls
|
||||
|
||||
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# snk
|
||||
|
||||
Generates a snake game from a github user contributions grid and output a screen capture as gif
|
||||
10
action.yml
10
action.yml
@@ -1,10 +1,10 @@
|
||||
name: "github-contribution-grid-snake"
|
||||
description: ""
|
||||
name: "generate-snake-game-from-github-contribution-grid"
|
||||
description: "Generates a snake game from a github user contributions grid and output a screen capture as gif"
|
||||
author: "platane"
|
||||
|
||||
outputs:
|
||||
gif_out_path:
|
||||
description: ""
|
||||
description: "path of the generated gif"
|
||||
|
||||
runs:
|
||||
using: "docker"
|
||||
@@ -15,9 +15,9 @@ runs:
|
||||
|
||||
inputs:
|
||||
github_user_name:
|
||||
description: ""
|
||||
description: "github user name"
|
||||
required: true
|
||||
gif_out_path:
|
||||
description: ""
|
||||
description: "path of the generated gif"
|
||||
required: false
|
||||
default: "./github-contribution-grid-snake.gif"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "snk",
|
||||
"description": "Generates a snake game from a github user contributions grid and output a screen capture as gif",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"repository": "github:platane/snk",
|
||||
|
||||
3
packages/action/.gitignore
vendored
3
packages/action/.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
!dist
|
||||
!dist/build
|
||||
!dist/build
|
||||
out.gif
|
||||
5
packages/action/__tests__/dev.ts
Normal file
5
packages/action/__tests__/dev.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { generateContributionSnake } from "../generateContributionSnake";
|
||||
|
||||
generateContributionSnake("platane").then((buffer) => {
|
||||
process.stdout.write(buffer);
|
||||
});
|
||||
@@ -5,8 +5,8 @@ import { computeBestRun } from "@snk/compute";
|
||||
import { createGif } from "../gif-creator";
|
||||
|
||||
export const userContributionToGrid = (cells: Cell[]) => {
|
||||
const width = Math.max(...cells.map((c) => c.x));
|
||||
const height = Math.max(...cells.map((c) => c.y));
|
||||
const width = Math.max(0, ...cells.map((c) => c.x)) + 1;
|
||||
const height = Math.max(0, ...cells.map((c) => c.y)) + 1;
|
||||
|
||||
const grid = generateEmptyGrid(width, height);
|
||||
for (const c of cells) setColor(grid, c.x, c.y, c.k === 0 ? null : c.k);
|
||||
@@ -39,9 +39,9 @@ export const generateContributionSnake = async (userName: string) => {
|
||||
|
||||
const gameOptions = { maxSnakeLength: 5 };
|
||||
|
||||
const gifOptions = { delay: 20 };
|
||||
const gifOptions = { delay: 10 };
|
||||
|
||||
const commands = computeBestRun(grid0, snake0, gameOptions).slice(0, 50);
|
||||
const commands = computeBestRun(grid0, snake0, gameOptions);
|
||||
|
||||
const buffer = await createGif(
|
||||
grid0,
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
"name": "@snk/action",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@actions/core": "1.2.4",
|
||||
"@snk/gif-creator": "1.0.0",
|
||||
"@snk/github-user-contribution": "1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@actions/core": "1.2.4",
|
||||
"@zeit/ncc": "0.22.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "ncc build ./index.ts --out dist"
|
||||
"build": "ncc build ./index.ts --out dist",
|
||||
"dev": "ncc run __tests__/dev.ts --quiet | tail -n +2 > out.gif "
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ export const computeBestRun = (
|
||||
|
||||
const commands: Point[] = [];
|
||||
|
||||
let u = 100;
|
||||
let u = 500;
|
||||
|
||||
while (!isGridEmpty(g) && u-- > 0) {
|
||||
let direction;
|
||||
|
||||
@@ -22,7 +22,7 @@ export const run = async () => {
|
||||
|
||||
const gameOptions = { maxSnakeLength: 5 };
|
||||
|
||||
const grid0 = generateGrid(14, 7, { colors: [1, 2, 3, 4], emptyP: 3 });
|
||||
const grid0 = generateGrid(42, 7, { colors: [1, 2, 3, 4], emptyP: 3 });
|
||||
|
||||
const snake0 = [
|
||||
{ x: 4, y: -1 },
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"jsx": "preserve",
|
||||
"lib": ["dom", "ES2020"],
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
|
||||
Reference in New Issue
Block a user