mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
feat: core chunk 7
This commit is contained in:
1 parent
d726005c38
commit
01dd7ad9c6
39 files changed
+83
-87
No files matched your search
@@ -1,8 +1,8 @@
|
||||
import { octokit } from '../../LEGACY_core/github/octokit';
|
||||
import throwError from '../../LEGACY_core/node/throwError';
|
||||
import { RatingsInfo } from '../../commands/ratings';
|
||||
import { Region } from '../../constants/regions';
|
||||
import { DATABASE_REPO } from './getMidnightLeaderboard';
|
||||
import { octokit } from './octokit';
|
||||
|
||||
const ARCHIVED_RATINGS_CACHE: Record<
|
||||
Region,
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import discord from '../../../discord.json' assert { type: 'json' };
|
||||
import isDev from './isDev';
|
||||
|
||||
export default function getClientId() {
|
||||
return isDev() ? discord.client_id_dev : discord.client_id;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BlitzkriegRatingsLeaderboard } from '../../../scripts/buildRatingsLeaderboard';
|
||||
import { Region } from '../../constants/regions';
|
||||
import { octokit } from '../../LEGACY_core/github/octokit';
|
||||
import { octokit } from './octokit';
|
||||
|
||||
export const DATABASE_REPO = { owner: 'tresabhi', repo: 'blitzkrieg-db' };
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function isDev() {
|
||||
return process.env.NODE_ENV === 'development';
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import jsxToSvg from './jsxToSvg';
|
||||
import svgToPng from './svgToPng';
|
||||
|
||||
export default async function jsxToPng(jsx: JSX.Element) {
|
||||
const svg = await jsxToSvg(jsx);
|
||||
const png = svgToPng(svg);
|
||||
|
||||
return png;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import { readFile } from 'fs';
|
||||
import { join } from 'path';
|
||||
import satori from 'satori';
|
||||
import robotoBlackFile from '../../assets/fonts/Roboto-Black.ttf';
|
||||
import robotoBoldFile from '../../assets/fonts/Roboto-Bold.ttf';
|
||||
import robotoFile from '../../assets/fonts/Roboto.ttf';
|
||||
|
||||
const FONT_NAME = 'Roboto';
|
||||
const FONT_FILES = [robotoFile, robotoBoldFile, robotoBlackFile];
|
||||
|
||||
let roboto: Buffer;
|
||||
let robotoBold: Buffer;
|
||||
let robotoBlack: Buffer;
|
||||
|
||||
console.log('Importing fonts...');
|
||||
Promise.all(
|
||||
FONT_FILES.map(
|
||||
(file) =>
|
||||
new Promise<Buffer>((resolve, reject) => {
|
||||
const path = join(__dirname, file);
|
||||
|
||||
readFile(path, (error, data) => {
|
||||
if (error) reject(error);
|
||||
resolve(data);
|
||||
});
|
||||
}),
|
||||
),
|
||||
).then((data) => {
|
||||
[roboto, robotoBold, robotoBlack] = data;
|
||||
console.log('Fonts imported');
|
||||
});
|
||||
|
||||
export default async function jsxToSvg(jsx: JSX.Element) {
|
||||
return await satori(jsx, {
|
||||
width: 480,
|
||||
fonts: [
|
||||
{ data: roboto, name: FONT_NAME, weight: 400 },
|
||||
{ data: robotoBold, name: FONT_NAME, weight: 700 },
|
||||
{ data: robotoBlack, name: FONT_NAME, weight: 900 },
|
||||
],
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { Octokit } from '@octokit/rest';
|
||||
import { secrets } from '../../LEGACY_core/node/secrets';
|
||||
|
||||
export const octokit = new Octokit({ auth: secrets.GH_TOKEN });
|
||||
@@ -0,0 +1,5 @@
|
||||
import { Resvg } from '@resvg/resvg-js';
|
||||
|
||||
export default function svgToPng(svg: string) {
|
||||
return new Resvg(svg).render().asPng();
|
||||
}
|
||||
Reference in new issue
Block a user