Skip to content

Commit

Permalink
Add prettier config & tw plugin (#60)
Browse files Browse the repository at this point in the history
* Add prettier config & tw plugin

* Format Files & GH Action Check

* Mod jobs to only run on PR
  • Loading branch information
Lermatroid authored Jul 20, 2024
1 parent 4021ef2 commit d013718
Show file tree
Hide file tree
Showing 178 changed files with 6,507 additions and 4,916 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# .github/workflows/prettier.yml

name: Prettier Check

on: [pull_request]

jobs:
prettier-check:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "20"

- name: Install pnpm
run: |
npm install -g pnpm
- name: Install dependencies
run: pnpm install

- name: Run Prettier check
run: pnpm run format-check
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages/db/drizzle/meta/**
pnpm-lock.yaml
pnpm-workspace.yaml
**/package.json
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"plugins": ["prettier-plugin-tailwindcss"],
"tailwindConfig": "./apps/web/tailwind.config.js",
"semi": true,
"singleQuote": false,
"jsxSingleQuote": false,
"printWidth": 80,
"tabWidth": 4,
"useTabs": true
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

## Technologies Used

- TypeScript
- Next.js
- Drizzle ORM
- Tailwind CSS
- TypeScript
- Next.js
- Drizzle ORM
- Tailwind CSS

[![Vercel](https://static.rowdyhacks.org/img/powered-by-vercel.svg)](https://vercel.com/?utm_source=ACM%20UTSA&utm_campaign=oss)

Expand Down
21 changes: 12 additions & 9 deletions apps/backup/src/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const uploadToS3 = async ({ name, path }: { name: string; path: string }) => {
Bucket: bucket,
Key: name,
Body: createReadStream(path),
})
}),
);

console.log("Backup uploaded to S3...");
Expand All @@ -35,14 +35,17 @@ const dumpToFile = async (path: string) => {
console.log("Dumping DB to file...");

await new Promise((resolve, reject) => {
exec(`pg_dump ${env.BACKUP_DATABASE_URL} -F t | gzip > ${path}`, (error, stdout, stderr) => {
if (error) {
reject({ error: JSON.stringify(error), stderr });
return;
}

resolve(undefined);
});
exec(
`pg_dump ${env.BACKUP_DATABASE_URL} -F t | gzip > ${path}`,
(error, stdout, stderr) => {
if (error) {
reject({ error: JSON.stringify(error), stderr });
return;
}

resolve(undefined);
},
);
});

console.log("DB dumped to file...");
Expand Down
5 changes: 4 additions & 1 deletion apps/backup/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ job.start();

console.log("Backup cron scheduled...");

serve({ fetch: app.fetch, port: process.env.PORT ? parseInt(process.env.PORT) : 3000 });
serve({
fetch: app.fetch,
port: process.env.PORT ? parseInt(process.env.PORT) : 3000,
});

console.log("Server started...");
20 changes: 10 additions & 10 deletions apps/backup/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
42 changes: 28 additions & 14 deletions apps/bot/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ const client = new Client({
client.commands = new Collection();

const commandsPath = path.join(__dirname, "commands");
const commandFiles = readdirSync(commandsPath).filter((file) => file.endsWith(".ts"));
const commandFiles = readdirSync(commandsPath).filter((file) =>
file.endsWith(".ts"),
);
for (const file of commandFiles) {
console.log(`[Loading Command] ${file}`);
const filePath = path.join(commandsPath, file);
Expand All @@ -43,18 +45,22 @@ for (const file of commandFiles) {
client.commands.set(command.data.name, command);
} else {
console.log(
`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`
`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`,
);
}
}
}
console.log(`Loaded ${client.commands.size} Commands`);

client.on(Events.InteractionCreate, async (interaction) => {
if (interaction.isChatInputCommand()) {
const command = interaction.client.commands.get(interaction.commandName);
const command = interaction.client.commands.get(
interaction.commandName,
);

if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
console.error(
`No command matching ${interaction.commandName} was found.`,
);
return;
}

Expand Down Expand Up @@ -132,9 +138,13 @@ app.get("/postMsgToServer", (h) => {
.setColor(0x0099ff)
.setTitle("Verification")
.setURL(c.siteUrl)
.setAuthor({ name: c.botName, iconURL: c.siteUrl + c.icon.md, url: c.siteUrl })
.setAuthor({
name: c.botName,
iconURL: c.siteUrl + c.icon.md,
url: c.siteUrl,
})
.setDescription(
`**Verify your registration for ${c.hackathonName} ${c.itteration} to gain access to the rest of the server!**\n\nClick the "verify" button below to begin the verification process.\n\u200B`
`**Verify your registration for ${c.hackathonName} ${c.itteration} to gain access to the rest of the server!**\n\nClick the "verify" button below to begin the verification process.\n\u200B`,
)
.setThumbnail(`${c.siteUrl}${c.icon.md}`)
.setFooter({
Expand All @@ -145,7 +155,7 @@ app.get("/postMsgToServer", (h) => {
const channel = client.channels.cache.get(
serverType === "dev"
? (process.env.DISCORD_DEV_VERIFY_CHANNEL_ID as string)
: (process.env.DISCORD_PROD_VERIFY_CHANNEL_ID as string)
: (process.env.DISCORD_PROD_VERIFY_CHANNEL_ID as string),
);

if (!channel || !channel.isTextBased()) {
Expand Down Expand Up @@ -198,25 +208,29 @@ app.post("/api/checkDiscordVerification", async (h) => {
return h.json({ success: false });
}

const { discordRole: userGroupRoleName } = (c.groups as Record<string, { discordRole: string }>)[
Object.keys(c.groups)[user.group]
];
const { discordRole: userGroupRoleName } = (
c.groups as Record<string, { discordRole: string }>
)[Object.keys(c.groups)[user.group]];

const guild = client.guilds.cache.get(verification.guild);
if (!guild) {
console.log("failed cause of no guild on intereaction");
return h.json({ success: false });
}

const role = guild.roles.cache.find((role) => role.name === c.botParticipantRole);
const userGroupRole = guild.roles.cache.find((role) => role.name === userGroupRoleName);
const role = guild.roles.cache.find(
(role) => role.name === c.botParticipantRole,
);
const userGroupRole = guild.roles.cache.find(
(role) => role.name === userGroupRoleName,
);

if (!role || !userGroupRole) {
console.log(
"failed cause could not find a role, was looking for group " +
user.group +
" called " +
userGroupRoleName
userGroupRoleName,
);
return h.json({ success: false });
}
Expand Down
4 changes: 3 additions & 1 deletion apps/bot/commands/ping.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { SlashCommandBuilder, type CommandInteraction } from "discord.js";

export const data = new SlashCommandBuilder().setName("ping").setDescription("Replies with Pong!");
export const data = new SlashCommandBuilder()
.setName("ping")
.setDescription("Replies with Pong!");

export const execute = async (interaction: CommandInteraction) => {
await interaction.reply("Pong!");
Expand Down
41 changes: 28 additions & 13 deletions apps/bot/deploy-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import path from "node:path";
const args = process.execArgv;

if (!args.includes("--prod") && !args.includes("--dev")) {
console.error("You must specify either --prod or --dev when deploying commands.");
console.error(
"You must specify either --prod or --dev when deploying commands.",
);
process.exit(1);
}

Expand All @@ -14,7 +16,9 @@ const runType: "dev" | "prod" = args.includes("--prod") ? "prod" : "dev";
const commands = [];
// Grab all the command folders from the commands directory you created earlier
const commandsPath = path.join(__dirname, "commands");
const commandFiles = fs.readdirSync(commandsPath).filter((file) => file.endsWith(".ts"));
const commandFiles = fs
.readdirSync(commandsPath)
.filter((file) => file.endsWith(".ts"));
// Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
Expand All @@ -23,7 +27,7 @@ for (const file of commandFiles) {
commands.push(command.data.toJSON());
} else {
console.log(
`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`
`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`,
);
}
}
Expand All @@ -34,34 +38,45 @@ const rest = new REST().setToken(process.env.DISCORD_SECRET_TOKEN as string);
// and deploy your commands!
(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);
console.log(
`Started refreshing ${commands.length} application (/) commands.`,
);

// The put method is used to fully refresh all commands in the guild with the current set
if (runType === "dev") {
const data = await rest.put(
Routes.applicationGuildCommands(
process.env.DISCORD_CLIENT_ID as string,
process.env.DISCORD_DEV_SERVER_ID as string
process.env.DISCORD_DEV_SERVER_ID as string,
),
{
body: commands,
}
},
);
console.log(
`Successfully reloaded ${(data as any).length} application (/) commands.`,
);
console.log(`Successfully reloaded ${(data as any).length} application (/) commands.`);
} else {
const data = await rest.put(
Routes.applicationGuildCommands(
process.env.DISCORD_CLIENT_ID as string,
process.env.DISCORD_PROD_SERVER_ID as string
process.env.DISCORD_PROD_SERVER_ID as string,
),
{
body: commands,
}
},
);
await rest.put(
Routes.applicationCommands(
process.env.DISCORD_CLIENT_ID as string,
),
{
body: commands,
},
);
console.log(
`Successfully reloaded ${(data as any).length} application (/) commands.`,
);
await rest.put(Routes.applicationCommands(process.env.DISCORD_CLIENT_ID as string), {
body: commands,
});
console.log(`Successfully reloaded ${(data as any).length} application (/) commands.`);
}
} catch (error) {
// And of course, make sure you catch and log any errors!
Expand Down
28 changes: 14 additions & 14 deletions apps/web/components.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": true,
"tailwind": {
"config": "tailwind.config.js",
"css": "src/app/globals.css",
"baseColor": "zinc",
"cssVariables": true
},
"aliases": {
"components": "@/components/shadcn",
"utils": "@/lib/utils/client/cn"
}
}
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": true,
"tailwind": {
"config": "tailwind.config.js",
"css": "src/app/globals.css",
"baseColor": "zinc",
"cssVariables": true
},
"aliases": {
"components": "@/components/shadcn",
"utils": "@/lib/utils/client/cn"
}
}
10 changes: 5 additions & 5 deletions apps/web/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
Loading

0 comments on commit d013718

Please sign in to comment.