Skip to content

Commit

Permalink
update prettier config
Browse files Browse the repository at this point in the history
  • Loading branch information
fitztrev committed Jan 23, 2024
1 parent 2c94a8b commit 79fe5a8
Show file tree
Hide file tree
Showing 29 changed files with 261 additions and 424 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/tauri-publish.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: "Publish"
name: 'Publish'

on:
push:
tags:
- "v*"
- 'v*'
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -40,7 +40,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version
releaseName: "Broadcaster v__VERSION__"
releaseBody: "See the assets to download this version and install."
releaseName: 'Broadcaster v__VERSION__'
releaseBody: 'See the assets to download this version and install.'
releaseDraft: false
prerelease: true
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"printWidth": 120,
"arrowParens": "avoid"
}
6 changes: 1 addition & 5 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"recommendations": [
"Vue.volar",
"tauri-apps.tauri-vscode",
"rust-lang.rust-analyzer"
]
"recommendations": ["Vue.volar", "tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"]
}
27 changes: 12 additions & 15 deletions sample-data/generate/add-broadcasts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { faker } from "@faker-js/faker";
import { faker } from '@faker-js/faker';

interface NewBroadcast {
name: string;
Expand All @@ -24,11 +24,11 @@ for (let i = 1; i <= 10; i++) {
tier: faker.number.int({ min: 3, max: 5 }),
};

const response = await fetch("http://localhost:8080/broadcast/new", {
method: "POST",
const response = await fetch('http://localhost:8080/broadcast/new', {
method: 'POST',
headers: {
Authorization: "Bearer lip_admin",
"Content-Type": "application/json",
Authorization: 'Bearer lip_admin',
'Content-Type': 'application/json',
},
body: JSON.stringify(broadcast),
});
Expand All @@ -47,17 +47,14 @@ for (let i = 1; i <= 10; i++) {
startsAt: faker.date.future().getTime(),
};

const response = await fetch(
`http://localhost:8080/broadcast/${broadcastResult.tour.id}/new`,
{
method: "POST",
headers: {
Authorization: "Bearer lip_admin",
"Content-Type": "application/json",
},
body: JSON.stringify(round),
const response = await fetch(`http://localhost:8080/broadcast/${broadcastResult.tour.id}/new`, {
method: 'POST',
headers: {
Authorization: 'Bearer lip_admin',
'Content-Type': 'application/json',
},
);
body: JSON.stringify(round),
});

if (!response.ok) {
console.error(response.statusText);
Expand Down
65 changes: 25 additions & 40 deletions sample-data/generate/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from "fs";
import path from "path";
import { faker } from "@faker-js/faker";
import { Chess } from "chess.js";
import fs from 'fs';
import path from 'path';
import { faker } from '@faker-js/faker';
import { Chess } from 'chess.js';

function writeToFile(filename: number, pgn: string) {
const filePath = path.join(outputFolder, `game-${filename}.pgn`);
Expand All @@ -12,47 +12,39 @@ function writeToFile(filename: number, pgn: string) {

const outputFolder = process.argv[2];
if (!outputFolder) {
console.log("Usage: pnpm esrun index.ts <output-folder>");
console.log('Usage: pnpm esrun index.ts <output-folder>');
process.exit(1);
}

const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));

const country = faker.location.country();
const eventName = `${faker.company.name()} Invitational`;
const location = `${faker.location.city()} ${country}`;

const date = faker.date.recent();
const pgnDate = `${date.getFullYear()}.${
date.getMonth() + 1
}.${date.getDate()}`;
const pgnDate = `${date.getFullYear()}.${date.getMonth() + 1}.${date.getDate()}`;

const games = new Map<number, Chess>();

for (let i = 1; i <= 16; i++) {
const game = new Chess();

game.header("Event", eventName);
game.header("Site", location);
game.header("Date", pgnDate);
game.header("Round", faker.number.int(10).toString());
game.header("TimeControl", "15 min/game + 10 sec/move");
game.header("White", faker.person.fullName());
game.header("Black", faker.person.fullName());
game.header(
"WhiteElo",
faker.number.int({ min: 1000, max: 2700 }).toString(),
);
game.header(
"BlackElo",
faker.number.int({ min: 1000, max: 2700 }).toString(),
);
game.header("Result", "*");

for (const title of ["WhiteTitle", "BlackTitle"]) {
game.header('Event', eventName);
game.header('Site', location);
game.header('Date', pgnDate);
game.header('Round', faker.number.int(10).toString());
game.header('TimeControl', '15 min/game + 10 sec/move');
game.header('White', faker.person.fullName());
game.header('Black', faker.person.fullName());
game.header('WhiteElo', faker.number.int({ min: 1000, max: 2700 }).toString());
game.header('BlackElo', faker.number.int({ min: 1000, max: 2700 }).toString());
game.header('Result', '*');

for (const title of ['WhiteTitle', 'BlackTitle']) {
faker.helpers.maybe(
() => {
game.header(title, faker.helpers.arrayElement(["GM", "IM", "FM"]));
game.header(title, faker.helpers.arrayElement(['GM', 'IM', 'FM']));
},
{
probability: 0.2,
Expand All @@ -64,13 +56,10 @@ for (let i = 1; i <= 16; i++) {
}

await Promise.all(
Array.from(games.keys()).map(async (i) => {
Array.from(games.keys()).map(async i => {
const game = games.get(i) as Chess;

while (
!game.isGameOver() &&
(game.history().length <= 100 * 2 || faker.datatype.boolean(0.9))
) {
while (!game.isGameOver() && (game.history().length <= 100 * 2 || faker.datatype.boolean(0.9))) {
const moves = game.moves();
if (moves.length === 0) break;

Expand All @@ -83,14 +72,10 @@ await Promise.all(
await sleep(faker.number.int({ min: 500, max: 2_000 }));
}

const result = game.isDraw()
? "1/2-1/2"
: game.turn() === "w"
? "0-1"
: "1-0";
game.header("Result", result);
const result = game.isDraw() ? '1/2-1/2' : game.turn() === 'w' ? '0-1' : '1-0';
game.header('Result', result);
writeToFile(i, game.pgn());
}),
);

console.log("Done");
console.log('Done');
7 changes: 1 addition & 6 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@
"active": true,
"targets": "all",
"identifier": "org.lichess.broadcaster",
"icon": [
"icons/128x128.png",
"icons/[email protected]",
"icons/icon.icns",
"icons/icon.ico"
]
"icon": ["icons/128x128.png", "icons/[email protected]", "icons/icon.icns", "icons/icon.ico"]
},
"security": {
"csp": null
Expand Down
39 changes: 13 additions & 26 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<script setup lang="ts">
import { useUserStore } from "./stores/user";
import { listen } from "@tauri-apps/api/event";
import { AccessTokenResponse, PgnPushResult } from "./types";
import { useLogStore } from "./stores/logs";
import { requestNotificationPermission } from "./notify";
import { useUserStore } from './stores/user';
import { listen } from '@tauri-apps/api/event';
import { AccessTokenResponse, PgnPushResult } from './types';
import { useLogStore } from './stores/logs';
import { requestNotificationPermission } from './notify';
const logs = useLogStore();
const user = useUserStore();
listen<AccessTokenResponse>("event::update_access_token", (event) => {
listen<AccessTokenResponse>('event::update_access_token', event => {
logs.clear();
user.setAccessToken(event.payload);
});
listen<number>("event::queue_size", (event) => {
listen<number>('event::queue_size', event => {
logs.queueSize = event.payload;
});
listen<PgnPushResult>("event::upload_success", (event) => {
listen<PgnPushResult>('event::upload_success', event => {
logs.moveCount += event.payload.response.moves;
logs.files.add(event.payload.file);
logs.info(`Uploaded ${event.payload.file}`);
});
listen<string>("event::upload_error", (event) => {
listen<string>('event::upload_error', event => {
logs.error(event.payload);
});
Expand All @@ -37,31 +37,18 @@ requestNotificationPermission();
<template>
<header class="mb-12 flex">
<router-link to="/">
<img
src="./assets/lichess-white.svg"
class="w-12 inline-block"
alt="Lichess logo"
/>
<img src="./assets/lichess-white.svg" class="w-12 inline-block" alt="Lichess logo" />
</router-link>

<div class="grow">
<nav class="flex space-x-4 justify-end">
<router-link to="/" class="nav-item" active-class="active">
Home
</router-link>
<router-link to="/" class="nav-item" active-class="active"> Home </router-link>

<router-link
to="/broadcasts"
class="nav-item"
active-class="active"
v-if="user.isLoggedIn()"
>
<router-link to="/broadcasts" class="nav-item" active-class="active" v-if="user.isLoggedIn()">
Broadcasts
</router-link>

<router-link to="/settings" class="nav-item" active-class="active">
Settings
</router-link>
<router-link to="/settings" class="nav-item" active-class="active"> Settings </router-link>
</nav>
</div>
</header>
Expand Down
24 changes: 8 additions & 16 deletions src/components/Broadcast.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script setup lang="ts">
import { computed } from "vue";
import { LichessBroadcast } from "../types";
import { router } from "../router";
import { useLogStore } from "../stores/logs";
import { relativeTimeDisplay, timestampToLocalDatetime } from "../utils";
import { computed } from 'vue';
import { LichessBroadcast } from '../types';
import { router } from '../router';
import { useLogStore } from '../stores/logs';
import { relativeTimeDisplay, timestampToLocalDatetime } from '../utils';
const logs = useLogStore();
Expand All @@ -25,7 +25,7 @@ const startsAt = computed<string>(() => {
function openRound(id: string) {
router.push({
name: "round",
name: 'round',
params: {
id,
},
Expand Down Expand Up @@ -57,23 +57,15 @@ function openRound(id: string) {
</a>
</h2>
</div>
<div
v-if="startsAt"
class="mt-3 flex items-center gap-x-2.5 text-xs leading-5 text-gray-400"
>
<div v-if="startsAt" class="mt-3 flex items-center gap-x-2.5 text-xs leading-5 text-gray-400">
<p class="truncate">{{ startsAt }}</p>
<svg viewBox="0 0 2 2" class="h-0.5 w-0.5 flex-none fill-gray-300">
<circle cx="1" cy="1" r="1" />
</svg>
<p class="whitespace-nowrap">{{ relativeTime }}</p>
</div>
</div>
<svg
class="h-5 w-5 flex-none text-gray-400"
viewBox="0 0 20 20"
fill="currentColor"
aria-hidden="true"
>
<svg class="h-5 w-5 flex-none text-gray-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path
fill-rule="evenodd"
d="M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z"
Expand Down
Loading

0 comments on commit 79fe5a8

Please sign in to comment.