✨ use bun as package manager and runner for the docke rcontainer, plus some tweak on the github action
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import { it, expect } from "bun:test";
|
||||
import { generateContributionSnake } from "../generateContributionSnake";
|
||||
import { parseOutputsOption } from "../outputsOptions";
|
||||
import { config } from "dotenv";
|
||||
config({ path: __dirname + "/../../../.env" });
|
||||
|
||||
jest.setTimeout(2 * 60 * 1000);
|
||||
|
||||
const silent = (handler: () => void | Promise<void>) => async () => {
|
||||
const originalConsoleLog = console.log;
|
||||
@@ -43,5 +40,6 @@ it(
|
||||
fs.writeFileSync(outputs[0]!.filename, results[0]!);
|
||||
fs.writeFileSync(outputs[1]!.filename, results[1]!);
|
||||
fs.writeFileSync(outputs[2]!.filename, results[2]!);
|
||||
})
|
||||
}),
|
||||
{ timeout: 2 * 60 * 1000 }
|
||||
);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { parseEntry } from "../outputsOptions";
|
||||
import { it, expect } from "bun:test";
|
||||
|
||||
it("should parse options as json", () => {
|
||||
expect(
|
||||
|
||||
@@ -10,11 +10,9 @@
|
||||
"@snk/types": "1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vercel/ncc": "0.38.1",
|
||||
"dotenv": "16.4.5"
|
||||
"@vercel/ncc": "0.38.1"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "ncc build --external canvas --external gifsicle --out dist ./index.ts",
|
||||
"run:build": "INPUT_GITHUB_USER_NAME=platane INPUT_OUTPUTS='dist/out.svg' node dist/index.js"
|
||||
"build": "ncc build --external canvas --external gifsicle --out dist ./index.ts"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
"@snk/types": "1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"dotenv": "16.4.5",
|
||||
"@types/dat.gui": "0.7.13",
|
||||
"dat.gui": "0.7.9",
|
||||
"html-webpack-plugin": "5.6.0",
|
||||
|
||||
@@ -2,13 +2,11 @@ import path from "path";
|
||||
import HtmlWebpackPlugin from "html-webpack-plugin";
|
||||
import webpack from "webpack";
|
||||
import { getGithubUserContribution } from "@snk/github-user-contribution";
|
||||
import { config } from "dotenv";
|
||||
import type { Configuration as WebpackConfiguration } from "webpack";
|
||||
import {
|
||||
ExpressRequestHandler,
|
||||
type Configuration as WebpackDevServerConfiguration,
|
||||
} from "webpack-dev-server";
|
||||
config({ path: __dirname + "/../../.env" });
|
||||
|
||||
const demos: string[] = require("./demo.json");
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import { it, expect } from "bun:test";
|
||||
import { AnimationOptions, createGif } from "..";
|
||||
import * as grids from "@snk/types/__fixtures__/grid";
|
||||
import { snake3 as snake } from "@snk/types/__fixtures__/snake";
|
||||
@@ -7,8 +8,6 @@ import { createSnakeFromCells, nextSnake } from "@snk/types/snake";
|
||||
import { getBestRoute } from "@snk/solver/getBestRoute";
|
||||
import type { Options as DrawOptions } from "@snk/draw/drawWorld";
|
||||
|
||||
jest.setTimeout(20 * 1000);
|
||||
|
||||
const upscale = 1;
|
||||
const drawOptions: DrawOptions = {
|
||||
sizeDotBorderRadius: 2 * upscale,
|
||||
@@ -35,10 +34,46 @@ for (const key of [
|
||||
"small",
|
||||
"smallPacked",
|
||||
] as const)
|
||||
it(`should generate ${key} gif`, async () => {
|
||||
const grid = grids[key];
|
||||
it(
|
||||
`should generate ${key} gif`,
|
||||
async () => {
|
||||
const grid = grids[key];
|
||||
|
||||
const chain = [snake, ...getBestRoute(grid, snake)!];
|
||||
const chain = [snake, ...getBestRoute(grid, snake)!];
|
||||
|
||||
const gif = await createGif(
|
||||
grid,
|
||||
null,
|
||||
chain,
|
||||
drawOptions,
|
||||
animationOptions
|
||||
);
|
||||
|
||||
expect(gif).toBeDefined();
|
||||
|
||||
fs.writeFileSync(path.resolve(dir, key + ".gif"), gif);
|
||||
},
|
||||
{ timeout: 20 * 1000 }
|
||||
);
|
||||
|
||||
it(
|
||||
`should generate swipper`,
|
||||
async () => {
|
||||
const grid = grids.smallFull;
|
||||
let snk = createSnakeFromCells(
|
||||
Array.from({ length: 6 }, (_, i) => ({ x: i, y: -1 }))
|
||||
);
|
||||
|
||||
const chain = [snk];
|
||||
for (let y = -1; y < grid.height; y++) {
|
||||
snk = nextSnake(snk, 0, 1);
|
||||
chain.push(snk);
|
||||
|
||||
for (let x = grid.width - 1; x--; ) {
|
||||
snk = nextSnake(snk, (y + 100) % 2 ? 1 : -1, 0);
|
||||
chain.push(snk);
|
||||
}
|
||||
}
|
||||
|
||||
const gif = await createGif(
|
||||
grid,
|
||||
@@ -50,29 +85,7 @@ for (const key of [
|
||||
|
||||
expect(gif).toBeDefined();
|
||||
|
||||
fs.writeFileSync(path.resolve(dir, key + ".gif"), gif);
|
||||
});
|
||||
|
||||
it(`should generate swipper`, async () => {
|
||||
const grid = grids.smallFull;
|
||||
let snk = createSnakeFromCells(
|
||||
Array.from({ length: 6 }, (_, i) => ({ x: i, y: -1 }))
|
||||
);
|
||||
|
||||
const chain = [snk];
|
||||
for (let y = -1; y < grid.height; y++) {
|
||||
snk = nextSnake(snk, 0, 1);
|
||||
chain.push(snk);
|
||||
|
||||
for (let x = grid.width - 1; x--; ) {
|
||||
snk = nextSnake(snk, (y + 100) % 2 ? 1 : -1, 0);
|
||||
chain.push(snk);
|
||||
}
|
||||
}
|
||||
|
||||
const gif = await createGif(grid, null, chain, drawOptions, animationOptions);
|
||||
|
||||
expect(gif).toBeDefined();
|
||||
|
||||
fs.writeFileSync(path.resolve(dir, "swipper.gif"), gif);
|
||||
});
|
||||
fs.writeFileSync(path.resolve(dir, "swipper.gif"), gif);
|
||||
},
|
||||
{ timeout: 20 * 1000 }
|
||||
);
|
||||
|
||||
@@ -11,10 +11,9 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/gifsicle": "5.2.2",
|
||||
"@types/tmp": "0.2.6",
|
||||
"@vercel/ncc": "0.38.1"
|
||||
"@types/tmp": "0.2.6"
|
||||
},
|
||||
"scripts": {
|
||||
"benchmark": "ncc run __tests__/benchmark.ts --quiet"
|
||||
"benchmark": "bun __tests__/benchmark.ts"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { getGithubUserContribution } from "..";
|
||||
import { config } from "dotenv";
|
||||
config({ path: __dirname + "/../../../.env" });
|
||||
import { describe, it, expect } from "bun:test";
|
||||
|
||||
describe("getGithubUserContribution", () => {
|
||||
const promise = getGithubUserContribution("platane", {
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
{
|
||||
"name": "@snk/github-user-contribution",
|
||||
"version": "1.0.0",
|
||||
"devDependencies": {
|
||||
"dotenv": "16.4.5"
|
||||
}
|
||||
"version": "1.0.0"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { it, expect } from "bun:test";
|
||||
import { getBestRoute } from "../getBestRoute";
|
||||
import { snake3, snake4 } from "@snk/types/__fixtures__/snake";
|
||||
import {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { it, expect } from "bun:test";
|
||||
import { getBestRoute } from "../getBestRoute";
|
||||
import { Color, createEmptyGrid, setColor } from "@snk/types/grid";
|
||||
import { createSnakeFromCells, snakeToCells } from "@snk/types/snake";
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { it, expect } from "bun:test";
|
||||
import { createEmptyGrid } from "@snk/types/grid";
|
||||
import { getHeadX, getHeadY } from "@snk/types/snake";
|
||||
import { snake3 } from "@snk/types/__fixtures__/snake";
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { it, expect } from "bun:test";
|
||||
import { createSnakeFromCells } from "@snk/types/snake";
|
||||
import { getPathToPose } from "../getPathToPose";
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { it, expect, describe } from "bun:test";
|
||||
import { sortPush } from "../utils/sortPush";
|
||||
|
||||
const sortFn = (a: number, b: number) => a - b;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { it, expect } from "bun:test";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import { createSvg, DrawOptions as DrawOptions } from "..";
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { it, expect } from "bun:test";
|
||||
import { minifyCss } from "../css-utils";
|
||||
|
||||
it("should minify css", () => {
|
||||
@@ -6,7 +7,7 @@ it("should minify css", () => {
|
||||
.c {
|
||||
color : red ;
|
||||
}
|
||||
|
||||
|
||||
`)
|
||||
).toBe(".c{color:red}");
|
||||
|
||||
@@ -17,10 +18,10 @@ it("should minify css", () => {
|
||||
color : red ;
|
||||
}
|
||||
|
||||
# {
|
||||
# {
|
||||
animation: linear 10;
|
||||
}
|
||||
|
||||
|
||||
`)
|
||||
).toBe(".c{top:0;color:red}#{animation:linear 10}");
|
||||
});
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { it, expect, test } from "bun:test";
|
||||
import { createEmptyGrid, setColor, getColor, isInside, Color } from "../grid";
|
||||
|
||||
it("should set / get cell", () => {
|
||||
const grid = createEmptyGrid(2, 3);
|
||||
|
||||
expect(getColor(grid, 0, 1)).toBe(0);
|
||||
expect(getColor(grid, 0, 1)).toBe(0 as any);
|
||||
|
||||
setColor(grid, 0, 1, 1 as Color);
|
||||
|
||||
expect(getColor(grid, 0, 1)).toBe(1);
|
||||
expect(getColor(grid, 0, 1)).toBe(1 as any);
|
||||
});
|
||||
|
||||
test.each([
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { it, expect } from "bun:test";
|
||||
import {
|
||||
createSnakeFromCells,
|
||||
nextSnake,
|
||||
|
||||
Reference in New Issue
Block a user