Skip to content

Commit d2cf911

Browse files
authored
use canvas instead of external API (#8)
1 parent 6550988 commit d2cf911

File tree

8 files changed

+43310
-418
lines changed

8 files changed

+43310
-418
lines changed

dist/index.js

Lines changed: 42735 additions & 397 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/sourcemap-register.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,21 @@
2424
},
2525
"scripts": {
2626
"build": "tsc",
27-
"build:dist": "yarn build && ncc build -o dist --source-map",
27+
"build:dist": "yarn build && ncc build -o dist",
2828
"format-n-lint": "biome check",
2929
"format-n-lint:fix": "biome check --write",
3030
"precommit": "yarn format-n-lint:fix && yarn build:dist",
3131
"prepare": "husky || true"
3232
},
3333
"dependencies": {
34-
"@actions/core": "^1.11.1"
34+
"@actions/core": "^1.11.1",
35+
"jimp": "^1.6.0"
3536
},
3637
"devDependencies": {
3738
"@biomejs/biome": "^1.9.4",
38-
"@types/node": "^22.10.2",
39+
"@types/node": "^22.13.14",
3940
"@vercel/ncc": "^0.38.3",
4041
"husky": "^9.1.7",
41-
"typescript": "^5.7.2"
42+
"typescript": "^5.8.2"
4243
}
4344
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const run = async (): Promise<void> => {
119119
}
120120

121121
if (teamsURLs.length > 0) {
122-
const teamsPayload = normalizeTeamsPayload(
122+
const teamsPayload = await normalizeTeamsPayload(
123123
title,
124124
text,
125125
color,

src/normalizers/teams.normalizer.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
import { Jimp } from 'jimp';
12
import type { Button, Field } from '../interfaces/input';
23
import type { TeamsPayload } from '../interfaces/teams-payload';
34

4-
export const normalizeTeamsPayload = (
5+
export const normalizeTeamsPayload = async (
56
title: string,
67
text: string,
78
color: string,
89
fields: Field[],
910
buttons: Button[],
10-
): TeamsPayload => {
11+
): Promise<TeamsPayload> => {
12+
const colorStrip = new Jimp({ width: 1, height: 3, color: `#${color}` });
13+
const colorStripBase64 = await colorStrip.getBase64('image/png');
14+
1115
return {
1216
type: 'message',
1317
attachments: [
@@ -46,8 +50,7 @@ export const normalizeTeamsPayload = (
4650
width: 'Full',
4751
},
4852
backgroundImage: {
49-
// TODO: Replace with base64 template, but no idea how that works...
50-
url: `https://singlecolorimage.com/get/${color}/1x3`,
53+
url: colorStripBase64,
5154
fillMode: 'RepeatHorizontally',
5255
},
5356
},

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"compilerOptions": {
33
"target": "es6",
4-
"module": "commonjs",
4+
"module": "NodeNext",
55
"outDir": "./lib",
66
"rootDir": "./src",
77
"strict": true,
88
"noImplicitAny": false,
9-
"esModuleInterop": true
9+
"esModuleInterop": true,
10+
"moduleResolution": "nodenext"
1011
},
1112
"include": ["src/**/*"],
1213
"exclude": ["node_modules", "**/*.test.ts"]

0 commit comments

Comments
 (0)