fix: use import.meta.env.

This commit is contained in:
tresabhi committed 2024-11-29 12:11:51 -06:00
1 parent d68870c254
commit c0d16b51de
10 files changed
+18 -18

No files matched your search

+1 -1
View File
@@ -2,5 +2,5 @@ import { assertSecret } from '@blitzkit/core';
import { ShardingManager } from 'discord.js';
export const manager = new ShardingManager('dist/bot/workers/bot.js', {
token: assertSecret(process.env.DISCORD_TOKEN),
token: assertSecret(import.meta.env.DISCORD_TOKEN),
});
@@ -115,7 +115,7 @@ export const commands = Promise.allSettled(COMMANDS_RAW).then((rawCommands) => {
);
});
const rest = new REST().setToken(assertSecret(process.env.DISCORD_TOKEN));
const rest = new REST().setToken(assertSecret(import.meta.env.DISCORD_TOKEN));
commands.then((awaitedCommands) => {
const body = Object.values(awaitedCommands).map((registry) =>
@@ -123,7 +123,7 @@ commands.then((awaitedCommands) => {
);
rest.put(
Routes.applicationCommands(assertSecret(process.env.DISCORD_CLIENT_ID)),
Routes.applicationCommands(assertSecret(import.meta.env.DISCORD_CLIENT_ID)),
{
body,
},
+1 -1
View File
@@ -6,4 +6,4 @@ console.log(`🟡 Launching bot ${client.shard?.ids[0]}`);
registerProcesses();
client.login(assertSecret(process.env.DISCORD_TOKEN));
client.login(assertSecret(import.meta.env.DISCORD_TOKEN));
+1 -1
View File
@@ -11,7 +11,7 @@ export async function isValidBlitzId(id: number, token?: string) {
const json = await fetch(
`https://api.wotblitz.${region}/wotb/account/info/?account_id=${id}&application_id=${assertSecret(
process.env.PUBLIC_WARGAMING_APPLICATION_ID,
import.meta.env.PUBLIC_WARGAMING_APPLICATION_ID,
)}${
token === undefined ? '' : `&access_token=${token}`
}&fields=account_id%2C-account_id`,
@@ -17,7 +17,7 @@ export async function getArchivedLatestSeasonNumber() {
const regionsURL = (
(await fetch(
`https://api.github.com/repos/tresabhi/${assertSecret(
process.env.PUBLIC_ASSET_REPO,
import.meta.env.PUBLIC_ASSET_REPO,
)}/git/trees/main`,
).then((response) => response.json())) as GitHubTrees
).tree.find(({ path }) => path === 'regions')!.url;
+5 -5
View File
@@ -1,3 +1,4 @@
import { assertSecret } from '@blitzkit/core';
import { mkdir, writeFile } from 'fs/promises';
import { parse as parsePath } from 'path';
import ProgressBar from 'progress';
@@ -6,7 +7,6 @@ import { dvp } from '../../../submodules/blitzkit-closed/src/dvp';
import { readStringDVPL } from '../src/core/blitz/readStringDVPL';
import { DATA } from './buildAssets/constants';
import { readYAMLDVPL } from './core/blitz/readYAMLDVPL';
import { assertSecret } from '@blitzkit/core';
import { writeDVPL } from './core/blitz/writeDVPL';
const versionTextFile = await readStringDVPL(`${DATA}/version.txt.dvpl`);
@@ -22,7 +22,7 @@ let patchIndex = 1;
while (true) {
const response = await fetch(
`${assertSecret(
process.env.WOTB_DLC_CDN,
import.meta.env.WOTB_DLC_CDN,
)}/dlc/s${currentVersion}_${patchIndex}.yaml`,
);
@@ -31,10 +31,10 @@ while (true) {
const data = parseYaml(await response.text());
const dvpm = await fetch(
`${assertSecret(process.env.WOTB_DLC_CDN)}/dlc/${data.dx11}`,
`${assertSecret(import.meta.env.WOTB_DLC_CDN)}/dlc/${data.dx11}`,
).then((response) => response.arrayBuffer());
const dvpd = await fetch(
`${assertSecret(process.env.WOTB_DLC_CDN)}/dlc/${data.dx11.replace(
`${assertSecret(import.meta.env.WOTB_DLC_CDN)}/dlc/${data.dx11.replace(
'.dvpm',
'.dvpd',
)}`,
@@ -63,7 +63,7 @@ while (true) {
console.log('Found dynamic content localizations; patching...');
const localizationsResponse = await fetch(
`${assertSecret(process.env.WOTB_DLC_CDN)}/dlc/${
`${assertSecret(import.meta.env.WOTB_DLC_CDN)}/dlc/${
data.dynamicContentLocalizationsDir
}/en.yaml`,
);
@@ -35,9 +35,9 @@ export async function currencies() {
}),
);
const glossary = await fetch(assertSecret(process.env.WOTB_GLOSSARY)).then(
(response) => response.json() as Promise<BlitzGlossary>,
);
const glossary = await fetch(
assertSecret(import.meta.env.WOTB_GLOSSARY),
).then((response) => response.json() as Promise<BlitzGlossary>);
await Promise.all(
Object.entries(glossary)
@@ -514,7 +514,7 @@ export async function definitions() {
const wargamingTankopedia = (await fetch(
`https://api.wotblitz.com/wotb/encyclopedia/vehicles/?application_id=${assertSecret(
process.env.PUBLIC_WARGAMING_APPLICATION_ID,
import.meta.env.PUBLIC_WARGAMING_APPLICATION_ID,
)}&fields=description`,
).then((response) => response.json())) as {
data: { [key: number]: { description: null | string } };
@@ -7,8 +7,8 @@ export async function commitAssets(message: string, changes: FileChange[]) {
if (changes.length === 0) return;
await commitMultipleFiles(
assertSecret(process.env.PUBLIC_ASSET_REPO),
assertSecret(process.env.PUBLIC_ASSET_BRANCH),
assertSecret(import.meta.env.PUBLIC_ASSET_REPO),
assertSecret(import.meta.env.PUBLIC_ASSET_BRANCH),
`${message} - ${new Date().toDateString()}`,
changes,
);
+1 -1
View File
@@ -5,5 +5,5 @@ import { Octokit } from '@octokit/rest';
Octokit.plugin(throttling);
export const octokit = new Octokit({
auth: assertSecret(process.env.GH_TOKEN),
auth: assertSecret(import.meta.env.GH_TOKEN),
});