-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_lessons.js
More file actions
41 lines (35 loc) · 1.65 KB
/
debug_lessons.js
File metadata and controls
41 lines (35 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const fs = require('fs');
const path = require('path');
// Mock types to avoid import errors
const loadFile = (filePath) => {
const content = fs.readFileSync(filePath, 'utf8');
// Extract the array using regex or simple parsing
// This is a rough parser for the exported array
const match = content.match(/export const \w+Lessons: Lesson\[\] = (\[[\s\S]*?\]);/);
if (match) {
// We need to make the content valid JSON-ish to parse it, or evaluating it
// Evaluating is risky but easiest for this structure
// We'll simplisticly regex for keys
const lessons = [];
const idMatches = content.matchAll(/id:\s*['"](.+?)['"]/g);
const titleMatches = content.matchAll(/title:\s*['"](.+?)['"]/g);
const langMatches = content.matchAll(/language:\s*['"](.+?)['"]/g);
const ids = [...idMatches].map(m => m[1]);
const titles = [...titleMatches].map(m => m[1]);
const langs = [...langMatches].map(m => m[1]);
return { ids, titles, langs, count: ids.length };
}
return { error: "Could not parse" };
};
const python = loadFile('src/data/lessons/python.ts');
const js = loadFile('src/data/lessons/javascript.ts');
const cpp = loadFile('src/data/lessons/cpp.ts');
console.log('Python Check:', python.count, 'lessons');
console.log('Sample IDs:', python.ids.slice(0, 3));
console.log('Languages found:', [...new Set(python.langs)]);
console.log('---');
console.log('JS Check:', js.count, 'lessons');
console.log('Languages found:', [...new Set(js.langs)]);
console.log('---');
console.log('CPP Check:', cpp.count, 'lessons');
console.log('Languages found:', [...new Set(cpp.langs)]);