Skip to content

Commit

Permalink
move everything to src folder
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Aug 27, 2024
1 parent 760e90f commit 79218c9
Show file tree
Hide file tree
Showing 64 changed files with 30 additions and 27 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
"name": "complibot-submissions",
"version": "1.0.0",
"description": "Fully automated texture pushing and submission system for the Faithful Discord servers.",
"main": "index.ts",
"main": "src/index.ts",
"scripts": {
"start": "node -r ts-node/register -r tsconfig-paths/register index.ts",
"dev": "nodemon -r tsconfig-paths/register --ignore resources/ --ignore backups/ index.ts",
"start": "node -r ts-node/register -r tsconfig-paths/register src/index.ts",
"dev": "nodemon -r tsconfig-paths/register --ignore resources/ --ignore backups/ src/index.ts",
"prettier": "prettier \"{,!(node_modules)/**/}*.ts\" --config .prettierrc --write"
},
"devDependencies": {
"@types/node": "^22.4.1",
"@types/node": "^22.5.0",
"nodemon": "^3.1.4",
"prettier": "^3.3.3"
},
"dependencies": {
"@napi-rs/canvas": "^0.1.54",
"@octokit/rest": "^20.1.1",
"axios": "^1.7.4",
"axios": "^1.7.5",
"cron": "^3.1.7",
"discord.js": "^14.15.3",
"dotenv": "^16.4.5",
Expand Down
28 changes: 14 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { mkdirSync, writeFile } from "fs";
import axios from "axios";
import type { Contribution, Pack, PackFile, Texture } from "@interfaces/database";
import { TextChannel, Client, Message } from "discord.js";
import { join, sep } from "path";

export interface DownloadableMessage {
url: string;
Expand Down Expand Up @@ -127,12 +128,12 @@ export async function downloadTexture(
for (const path of paths) {
// write file to every version of a path
for (const version of path.versions) {
const fullPath = `${baseFolder}/${packFolder}/${version}/${path.name}`;
const fullPath = join(baseFolder, packFolder, version, path.name);

// trim last bit to get folder tree
mkdirSync(fullPath.slice(0, fullPath.lastIndexOf("/")), { recursive: true });
mkdirSync(fullPath.slice(0, fullPath.lastIndexOf(sep)), { recursive: true });

// better to use the callback version because .then and .catch are sent to the same output
// something is always being logged when debugging so the callback version is simpler
writeFile(fullPath, imageFile, (err) => {
if (DEBUG) return console.log(err ?? `Added texture to path: ${fullPath}`);
});
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import formattedDate from "@helpers/formattedDate";

import pushToGitHub from "@functions/pushToGitHub";
import type { PackFile } from "@interfaces/database";
import { join } from "path";
const DEBUG = process.env.DEBUG.toLowerCase() == "true";

/**
Expand All @@ -30,7 +31,7 @@ export default async function pushTextures(
continue;
}
for (const branch of settings.versions[edition]) {
const path = `${basePath}/${packGitHub.repo}/${branch}/`;
const path = join(basePath, packGitHub.repo, branch);

// don't create empty commits
if (!existsSync(path)) continue;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions index.ts → src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { fetchSettings } from "@functions/fetchSettings";
import handleError from "@functions/handleError";
import { Client, GatewayIntentBits, Partials } from "discord.js";
import type { Event } from "@interfaces/discord";
import { join } from "path";

export default function startBot() {
const client = new Client({
Expand Down Expand Up @@ -47,9 +48,9 @@ export default function startBot() {
* EVENT HANDLER
* - see the ./events folder
*/
const eventsFiles = readdirSync("./events").filter((f) => f.endsWith(".ts"));
const eventsFiles = readdirSync(join(__dirname, "events")).filter((f) => f.endsWith(".ts"));
for (const file of eventsFiles) {
const event: Event = require(`./events/${file}`).default;
const event: Event = require(join(__dirname, "events", file)).default;

// catch invalid events
if (typeof event !== "object") continue;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"module": "commonjs",
"moduleResolution": "node",
"target": "ESNEXT",
"baseUrl": ".",
"baseUrl": "src",
"paths": {
"@functions/*": ["./functions/*"],
"@helpers/*": ["./helpers/*"],
Expand All @@ -15,7 +15,7 @@
"@submission/*": ["./functions/submission/*"],
"@images/*": ["./functions/images/*"],
"@interfaces/*": ["./interfaces/*"],
"@resources/*": ["./resources/*"],
"@resources/*": ["../resources/*"],
"@index": ["./index.ts"],
}
}
Expand Down

0 comments on commit 79218c9

Please sign in to comment.