Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE/standard_fix.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
## Type of Change

- [ ] New feature
- [ ] Bug fix
- [ ] Refactoring (no functional changes)
- [ ] Documentation update
- [ ] Infrastructure / CI/CD
Expand Down
2 changes: 1 addition & 1 deletion assets/index-D1cvIhyV.js → assets/index-CfVGc6kY.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/png" href="/CompTeamDemo/favicon.png" />
<link rel="icon" type="image/png" href="/CompTeam/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="IECSE's Official Competitive Programming Team at MIT Manipal" />
<meta property="og:title" content="IECSE Comp Team" />
<meta property="og:description" content="IECSE's Official Competitive Programming Team at MIT Manipal" />
<title>IECSE Comp Team</title>
<script type="module" crossorigin src="/CompTeamDemo/assets/index-D1cvIhyV.js"></script>
<link rel="stylesheet" crossorigin href="/CompTeamDemo/assets/index-CUDjpWEJ.css">
<script type="module" crossorigin src="/CompTeam/assets/index-CfVGc6kY.js"></script>
<link rel="stylesheet" crossorigin href="/CompTeam/assets/index-CUDjpWEJ.css">
</head>
<body>
<div id="root"></div>
Expand Down
20 changes: 16 additions & 4 deletions scripts/check-pages-root.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@ import path from 'node:path';
import { fileURLToPath } from 'node:url';

const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const built = fs.readFileSync(path.join(root, 'dist', 'index.html'), 'utf8');
const published = fs.readFileSync(path.join(root, 'index.html'), 'utf8');
const repositoryName = process.env.GITHUB_REPOSITORY?.split('/').pop() ?? 'CompTeamDemo';
const distHtml = path.join(root, 'dist', 'index.html');
const publishedHtml = path.join(root, 'index.html');

if (!fs.existsSync(distHtml)) {
throw new Error('Build output missing at dist/index.html. Run "npm run build" first.');
}
if (!fs.existsSync(publishedHtml)) {
throw new Error('Published index.html missing at repository root.');
}

const built = fs.readFileSync(distHtml, 'utf8');
const published = fs.readFileSync(publishedHtml, 'utf8');
const repositoryName =
process.env.GITHUB_REPOSITORY?.trim().replace(/\/+$/, '').replace(/\.git$/, '').split('/').pop() || 'CompTeam';

if (built.includes('src/main.tsx') || published.includes('src/main.tsx')) {
throw new Error('The repository root still contains a raw Vite source entry.');
Expand All @@ -29,7 +40,8 @@ if (!publishedUrls.some(url => url.includes('/assets/') && url.endsWith('.js'))
}

for (const url of publishedUrls) {
const file = path.join(root, url.slice(repositoryName.length + 2));
const cleanUrl = url.split(/[?#]/)[0];
const file = path.join(root, cleanUrl.slice(repositoryName.length + 2));
if (!fs.existsSync(file)) throw new Error(`Published asset is missing: ${url}`);
}

Expand Down
19 changes: 15 additions & 4 deletions scripts/sync-pages-root.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,32 @@ import { fileURLToPath } from 'node:url';

const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const dist = path.join(root, 'dist');
const distHtml = path.join(dist, 'index.html');
const distAssets = path.join(dist, 'assets');
const assets = path.join(root, 'assets');
const repositoryName = process.env.GITHUB_REPOSITORY?.split('/').pop() ?? 'CompTeamDemo';
const builtHtml = fs.readFileSync(path.join(dist, 'index.html'), 'utf8');
const repositoryName =
process.env.GITHUB_REPOSITORY?.trim().replace(/\/+$/, '').replace(/\.git$/, '').split('/').pop() || 'CompTeam';

if (!fs.existsSync(distHtml)) {
throw new Error('Build output missing at dist/index.html. Run "npm run build" first.');
}
if (!fs.existsSync(distAssets)) {
throw new Error('Compiled assets directory missing at dist/assets. Run "npm run build" first.');
}

const builtHtml = fs.readFileSync(distHtml, 'utf8');

if (builtHtml.includes('src/main.tsx') || !builtHtml.includes(`/${repositoryName}/assets/`)) {
throw new Error('The Vite build does not contain compiled assets for this repository.');
}

const resolvedAssets = fs.existsSync(assets) ? fs.realpathSync(assets) : path.resolve(assets);
if (path.relative(root, resolvedAssets) !== 'assets') {
if (path.resolve(resolvedAssets).toLowerCase() !== path.resolve(root, 'assets').toLowerCase()) {
throw new Error('Refusing to replace an asset directory outside the repository root.');
}

fs.rmSync(assets, { recursive: true, force: true });
fs.cpSync(path.join(dist, 'assets'), assets, { recursive: true });
fs.cpSync(distAssets, assets, { recursive: true });

for (const entry of fs.readdirSync(dist, { withFileTypes: true })) {
if (entry.name === 'assets') continue;
Expand Down
14 changes: 7 additions & 7 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ function Navigation({ currentView, setView }: { currentView: ViewState, setView:
return (
<nav className="nav-panel">
<div className="nav-brand">
<h1>CompTeam</h1>
<p>Competitive Programming</p>
<h1>IECSE</h1>
<p>Official Competitive Programming Team</p>
</div>
<ul className="nav-links">
<li>
<button
<button
aria-current={currentView === 'online' ? 'page' : undefined}
onClick={() => setView('online')}
>
Online Stats
</button>
</li>
<li>
<button
<button
aria-current={currentView === 'offline' ? 'page' : undefined}
onClick={() => setView('offline')}
>
Expand Down Expand Up @@ -67,7 +67,7 @@ function RatingCell({ ratingObj, platformName }: { ratingObj: RatingValue, platf

function OnlineStats() {
const updatedAt = ratingsData.length > 0 && ratingsData[0].updatedAt ? new Date(ratingsData[0].updatedAt).toLocaleString() : 'Never';

const [sortKey, setSortKey] = useState<SortKey>('name');
const [sortOrder, setSortOrder] = useState<SortOrder>('asc');
const [showRetired, setShowRetired] = useState(true);
Expand Down Expand Up @@ -126,7 +126,7 @@ function OnlineStats() {
</div>
</div>
</header>

<div className="table-wrapper">
<table>
<caption>Team member platform ratings</caption>
Expand Down Expand Up @@ -208,7 +208,7 @@ function OfflineStats() {
{sortedEvents.map((ev, i) => (
<article key={i} className="event-card">
<div className="event-meta">
<span>{new Date(ev.date).toLocaleDateString(undefined, { year: 'numeric', month: 'long', day: 'numeric'})}</span>
<span>{new Date(ev.date).toLocaleDateString(undefined, { year: 'numeric', month: 'long', day: 'numeric' })}</span>
</div>
<h3 className="event-title">{ev.event}</h3>
<div className="event-position">{ev.position}</div>
Expand Down
3 changes: 2 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { defineConfig } from 'vite'

// https://vite.dev/config/
export default defineConfig(() => {
const repositoryName = process.env.GITHUB_REPOSITORY?.split('/').pop() ?? 'CompTeamDemo'
const repositoryName =
process.env.GITHUB_REPOSITORY?.trim().replace(/\/+$/, '').replace(/\.git$/, '').split('/').pop() || 'CompTeam'

return {
root: 'site',
Expand Down
Loading