Skip to content

Commit 9515cfa

Browse files
authored
Merge pull request #41 from ivelin/dev
Dev
2 parents 244be4d + b702ac5 commit 9515cfa

File tree

27 files changed

+1439
-537
lines changed

27 files changed

+1439
-537
lines changed

.github/workflows/e2e-tests.yaml

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# .github/workflows/e2e-tests.yaml
2+
# File path: .github/workflows/e2e-tests.yaml
3+
# Runs CI for K12Beast, including E2E and server tests with build debugging
4+
25
name: Tests
36
on:
47
push:
@@ -13,8 +16,10 @@ jobs:
1316
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
1417
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
1518
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
16-
TEST_USER_EMAIL: ${{ secrets.TEST_USER_EMAIL }} # From GitHub Secrets
17-
TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }} # From GitHub Secrets
19+
TEST_USER_EMAIL: ${{ secrets.TEST_USER_EMAIL }}
20+
TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
21+
XAI_API_KEY: ${{ secrets.XAI_API_KEY }}
22+
XAI_MODEL_NAME: ${{ secrets.XAI_MODEL_NAME }}
1823
steps:
1924
- uses: actions/checkout@v4
2025
- uses: actions/setup-node@v4
@@ -46,9 +51,12 @@ jobs:
4651
runs-on: ubuntu-latest
4752
env:
4853
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
54+
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
4955
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
50-
TEST_USER_EMAIL: ${{ secrets.TEST_USER_EMAIL }} # From GitHub Secrets
51-
TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }} # From GitHub Secrets
56+
TEST_USER_EMAIL: ${{ secrets.TEST_USER_EMAIL }}
57+
TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
58+
XAI_API_KEY: ${{ secrets.XAI_API_KEY }}
59+
XAI_MODEL_NAME: ${{ secrets.XAI_MODEL_NAME }}
5260
steps:
5361
- uses: actions/checkout@v4
5462
- uses: actions/setup-node@v4
@@ -59,8 +67,22 @@ jobs:
5967
- name: Debug environment variables
6068
run: |
6169
echo "NEXT_PUBLIC_SUPABASE_URL: $NEXT_PUBLIC_SUPABASE_URL"
62-
echo "SUPABASE_SERVICE_ROLE_KEY: [REDACTED]" # Avoid logging sensitive data
63-
env | grep -E 'NEXT_PUBLIC_SUPABASE_URL|SUPABASE_SERVICE_ROLE_KEY'
70+
echo "NEXT_PUBLIC_SUPABASE_ANON_KEY: [REDACTED]"
71+
echo "SUPABASE_SERVICE_ROLE_KEY: [REDACTED]"
72+
echo "XAI_API_KEY: [REDACTED]"
73+
echo "XAI_MODEL_NAME: [REDACTED]"
74+
env | grep -E 'NEXT_PUBLIC_SUPABASE_URL|NEXT_PUBLIC_SUPABASE_ANON_KEY|SUPABASE_SERVICE_ROLE_KEY|XAI_API_KEY|XAI_MODEL_NAME'
75+
- name: Run build
76+
run: npm run build --verbose
77+
- name: Verify build manifest
78+
run: |
79+
if [ -f .next/build-manifest.json ]; then
80+
echo "build-manifest.json found"
81+
else
82+
echo "build-manifest.json missing"
83+
ls -la .next
84+
exit 1
85+
fi
6486
- name: Run Jest server tests
6587
run: npm run test:server
6688
- name: Upload server test report

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,7 @@ tmp/
5252
# ignore test artifacts
5353
playwright-report/
5454
test-results/
55-
playwright/
55+
playwright/
56+
57+
# ignore dynamically generated files
58+
public/sitemap.xml

next-sitemap.config.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// next-sitemap.config.js
2+
// File path: next-sitemap.config.js
3+
// Configures sitemap for K12Beast, including only root and /public/* pages
4+
// Scans src/app/public for page.tsx and src/content/docs for page.mdx, excluding all other routes
5+
6+
const fs = require('fs');
7+
const path = require('path');
8+
9+
const PUBLIC_DIR = path.join(process.cwd(), 'src/app/public');
10+
const DOCS_DIR = path.join(process.cwd(), 'src/content/docs');
11+
12+
function getPublicPaths(dir, prefix, fileName) {
13+
console.log(`[Sitemap Config] Scanning directory: ${dir}`);
14+
const paths = [];
15+
if (!fs.existsSync(dir)) {
16+
console.log(`[Sitemap Config] Directory not found: ${dir}`);
17+
return paths;
18+
}
19+
fs.readdirSync(dir).forEach(file => {
20+
const filePath = path.join(dir, file);
21+
if (fs.statSync(filePath).isDirectory()) {
22+
paths.push(...getPublicPaths(filePath, `${prefix}/${file}`, fileName));
23+
} else if (file === fileName) {
24+
const relativePath = prefix.endsWith('/public') ? '/public' : prefix;
25+
// Only include paths starting with /public/ or /public
26+
if (!relativePath.includes('[') && (relativePath === '/public' || relativePath.startsWith('/public/'))) {
27+
console.log(`[Sitemap Config] Including path: ${relativePath}`);
28+
paths.push({
29+
loc: relativePath,
30+
lastmod: new Date().toISOString(),
31+
changefreq: 'daily',
32+
priority: relativePath === '/public' ? 0.8 : 0.7,
33+
});
34+
} else {
35+
console.log(`[Sitemap Config] Excluding path: ${relativePath}`);
36+
}
37+
}
38+
});
39+
return paths;
40+
}
41+
42+
module.exports = {
43+
siteUrl: 'https://k12beast.com',
44+
generateRobotsTxt: true,
45+
generateIndexSitemap: false,
46+
// Prevent automatic inclusion of src/app routes
47+
exclude: ['/*'], // Exclude all routes by default
48+
additionalPaths: async () => {
49+
console.log('[Sitemap Config] Generating sitemap paths');
50+
console.log(`[Sitemap Config] Environment: CI=${process.env.CI || 'false'}`);
51+
const paths = [
52+
{
53+
loc: '/',
54+
lastmod: new Date().toISOString(),
55+
changefreq: 'daily',
56+
priority: 1.0,
57+
},
58+
];
59+
// Include all /public/* paths
60+
paths.push(...getPublicPaths(PUBLIC_DIR, '/public', 'page.tsx'));
61+
paths.push(...getPublicPaths(DOCS_DIR, '/public/docs', 'page.mdx'));
62+
console.log(`[Sitemap Config] Total paths generated: ${paths.length}`);
63+
return paths;
64+
},
65+
};

next.config.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,45 @@
1+
// next.config.ts
12
// File path: next.config.ts
23
// Configures Next.js for K12Beast, including MDX support for documentation pages
34
// Allows external image domains for testing and Supabase storage URLs
45
// Disables TypeScript build errors and source maps in development
56
// Sets cache control headers for source maps
6-
// Configures MDX to strip comments and frontmatter from rendering
7+
// Configures MDX to strip comments and frontmatter, with GFM support for tables
78

89
import type { NextConfig } from 'next';
910
import createMDX from '@next/mdx';
1011
import remarkFrontmatter from 'remark-frontmatter';
12+
import remarkGfm from 'remark-gfm';
1113
import remarkRemoveComments from 'remark-remove-comments';
1214
import { remove } from 'unist-util-remove';
1315

1416
// Custom remark plugin to remove frontmatter node from the MDX AST
1517
function remarkRemoveFrontmatter() {
1618
return (tree: any) => {
17-
remove(tree, { type: 'yaml' }); // Remove frontmatter (yaml node)
19+
remove(tree, { type: 'yaml' });
1820
return tree;
1921
};
2022
}
2123

2224
const nextConfig: NextConfig = {
2325
productionBrowserSourceMaps: false,
2426
typescript: {
25-
ignoreBuildErrors: true, // Disable TypeScript errors during build
27+
ignoreBuildErrors: true,
2628
},
2729
images: {
28-
domains: ['mockurl.com'], // For tests
30+
domains: ['mockurl.com'],
2931
remotePatterns: [
3032
{
3133
protocol: 'https',
32-
hostname: '*.supabase.co', // Allow any subdomain of supabase.co
33-
port: '', // Leave empty for default ports (80, 443)
34-
pathname: '/storage/v1/object/public/**', // Match Supabase storage paths
34+
hostname: '*.supabase.co',
35+
port: '',
36+
pathname: '/storage/v1/object/public/**',
3537
},
3638
],
3739
},
3840
webpack: (config, { dev }) => {
3941
if (dev) {
40-
config.devtool = false; // Disable source maps in dev mode
42+
config.devtool = false;
4143
}
4244
return config;
4345
},
@@ -54,17 +56,17 @@ const nextConfig: NextConfig = {
5456
},
5557
];
5658
},
57-
pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'], // Enable MDX pages
59+
pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'],
5860
};
5961

6062
const withMDX = createMDX({
6163
options: {
6264
remarkPlugins: [
63-
remarkFrontmatter, // Parse frontmatter
64-
remarkRemoveFrontmatter, // Remove frontmatter from rendering
65-
remarkRemoveComments, // Remove comments (e.g., lines starting with //)
65+
remarkFrontmatter,
66+
remarkRemoveFrontmatter,
67+
remarkRemoveComments,
68+
remarkGfm,
6669
],
67-
// Add rehype plugins here if needed in the future
6870
rehypePlugins: [],
6971
},
7072
});

0 commit comments

Comments
 (0)