mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 02:37:05 +02:00
feat: implemented dist package.json
This commit is contained in:
1 parent
e34a6c6e4b
commit
4c2b0253de
7 files changed
+46
-29
No files matched your search
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"main": "server.js",
|
||||
"main": "server.cjs",
|
||||
"scripts": {
|
||||
"start": "node --enable-source-maps server.cjs"
|
||||
"start": "node --enable-source-maps --trace-warnings server.cjs"
|
||||
}
|
||||
}
|
||||
+25
-18
@@ -1,5 +1,5 @@
|
||||
import { build } from 'esbuild';
|
||||
import { mkdirSync, rmSync, writeFileSync } from 'fs';
|
||||
import { copyFile, mkdir, rm, writeFile } from 'fs/promises';
|
||||
import { argv } from 'process';
|
||||
|
||||
const isProd = !argv.includes('--dev');
|
||||
@@ -9,21 +9,21 @@ const buildServer = argv.includes('--build=server') | buildAll;
|
||||
|
||||
if (isProd) {
|
||||
// only remove in production to ensure no time is wasted in dev
|
||||
console.log('Removing dist...');
|
||||
rmSync('dist', { recursive: true, force: true });
|
||||
console.log('🟡 Removing dist...');
|
||||
await rm('dist', { recursive: true, force: true });
|
||||
console.log('✅ Dist removed');
|
||||
|
||||
console.log('Creating dist...');
|
||||
mkdirSync('dist');
|
||||
console.log('🟡 Creating dist...');
|
||||
await mkdir('dist');
|
||||
console.log('✅ Dist created');
|
||||
|
||||
console.log('Caching tankopedia...');
|
||||
console.log('🟡 Caching tankopedia...');
|
||||
fetch('https://www.blitzstars.com/bs-tankopedia.json')
|
||||
.then((response) => response.text())
|
||||
.then((tankopedia) => {
|
||||
writeFileSync('./dist/tankopedia.json', tankopedia);
|
||||
console.log('Tankopedia cached');
|
||||
});
|
||||
.then((tankopedia) => writeFile('./dist/tankopedia.json', tankopedia))
|
||||
.then(() => console.log('✅ Tankopedia cached'));
|
||||
|
||||
console.log('Caching tank averages...');
|
||||
console.log('🟡 Caching tank averages...');
|
||||
fetch('https://www.blitzstars.com/api/tankaverages.json')
|
||||
.then((response) => response.json())
|
||||
.then((individualTankAverages) => {
|
||||
@@ -33,10 +33,17 @@ if (isProd) {
|
||||
tankAverages[individualTankAverage.tank_id] = individualTankAverage;
|
||||
});
|
||||
|
||||
writeFileSync('./dist/tankaverages.json', JSON.stringify(tankAverages));
|
||||
return writeFile(
|
||||
'./dist/tankaverages.json',
|
||||
JSON.stringify(tankAverages),
|
||||
);
|
||||
})
|
||||
.then(() => console.log('✅ Tank averages cached'));
|
||||
|
||||
console.log('Tank averages cached');
|
||||
});
|
||||
console.log('🟡 Copying package.json...');
|
||||
copyFile('package.dist.json', 'dist/package.json').then(() =>
|
||||
console.log('✅ package.json copied'),
|
||||
);
|
||||
}
|
||||
|
||||
const commonOptions = {
|
||||
@@ -56,25 +63,25 @@ const commonOptions = {
|
||||
};
|
||||
|
||||
if (buildBot) {
|
||||
console.log('Building bot...');
|
||||
console.log('🟡 Building bot...');
|
||||
build({
|
||||
...commonOptions,
|
||||
|
||||
entryPoints: ['src/bot.ts'],
|
||||
outfile: 'dist/bot.cjs',
|
||||
}).then(() => {
|
||||
console.log('Bot built');
|
||||
console.log('✅ Bot built');
|
||||
});
|
||||
}
|
||||
|
||||
if (buildServer) {
|
||||
console.log('Building server...');
|
||||
console.log('🟡 Building server...');
|
||||
build({
|
||||
...commonOptions,
|
||||
|
||||
entryPoints: ['src/server.ts'],
|
||||
outfile: 'dist/server.cjs',
|
||||
}).then(() => {
|
||||
console.log('Server built');
|
||||
console.log('✅ Server built');
|
||||
});
|
||||
}
|
||||
@@ -20,7 +20,7 @@ import { AccountInfo } from '../types/accountInfo.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: addStatTypeSubCommandGroups(
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { times } from 'lodash';
|
||||
import { theme } from '../../../stitches.config.js';
|
||||
import { MarginProps as RootMarginProps } from './Root.js';
|
||||
import { MarginInputProps } from './Root.js';
|
||||
|
||||
export enum MarginOrientation {
|
||||
Vertical,
|
||||
Horizontal,
|
||||
}
|
||||
|
||||
export interface MarginProps extends RootMarginProps {
|
||||
export interface MarginProps extends MarginInputProps {
|
||||
verticalSeparations: number;
|
||||
orientation?: MarginOrientation;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Margin, MarginOrientation } from './Margin.js';
|
||||
export const GRAPH_WIDTH = 544;
|
||||
export const GRAPH_HEIGHT = 320;
|
||||
|
||||
export interface MarginProps {
|
||||
export interface MarginInputProps {
|
||||
min: number;
|
||||
max: number;
|
||||
suffix?: string;
|
||||
@@ -15,8 +15,8 @@ export interface MarginProps {
|
||||
|
||||
export interface RootProps {
|
||||
children: ReactNode;
|
||||
verticalMargin?: MarginProps;
|
||||
horizontalMargin?: MarginProps;
|
||||
verticalMargin?: MarginInputProps;
|
||||
horizontalMargin?: MarginInputProps;
|
||||
separations?: number;
|
||||
xMinLabel: string;
|
||||
xMaxLabel: string;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default function throwError(message: string, cause: string) {
|
||||
export default function throwError(message: string, cause?: string) {
|
||||
return new Error(message, { cause });
|
||||
}
|
||||
@@ -1,21 +1,31 @@
|
||||
import { ButtonInteraction, CacheType } from 'discord.js';
|
||||
import { CYCLIC_API } from '../../../constants/cyclic.js';
|
||||
import normalizeInteractionReturnable from '../../../core/discord/normalizeInteractionReturnable.js';
|
||||
import throwError from '../../../core/node/throwError.js';
|
||||
import { commands } from '../index.js';
|
||||
|
||||
export default async function handleButton(
|
||||
interaction: ButtonInteraction<CacheType>,
|
||||
) {
|
||||
await interaction.deferUpdate();
|
||||
|
||||
const url = new URL(`${CYCLIC_API}/${interaction.customId}`);
|
||||
const commandName = url.pathname.split('/')[1];
|
||||
const button = commands[commandName]?.button;
|
||||
|
||||
if (!button) {
|
||||
console.error(`Button handler not found for "${commandName}"`);
|
||||
throwError(`Button handler not found for "${commandName}"`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (interaction.message.interaction?.user.id !== interaction.user.id) {
|
||||
interaction.followUp({
|
||||
ephemeral: true,
|
||||
content: 'You are not the author of this command.',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
await interaction.deferUpdate();
|
||||
await interaction.message.edit(
|
||||
await normalizeInteractionReturnable(button(interaction)),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user