-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport.js
More file actions
70 lines (58 loc) · 2.3 KB
/
Copy pathexport.js
File metadata and controls
70 lines (58 loc) · 2.3 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env node
// export.js — Generate a completion report from PROGRESS.md
// Run: npm run export
const fs = require('fs');
const path = require('path');
const ROOT = __dirname;
const PROGRESS_PATH = path.join(ROOT, 'PROGRESS.md');
if (!fs.existsSync(PROGRESS_PATH)) {
console.error('\nError: PROGRESS.md not found. Run npm run setup first.\n');
process.exit(1);
}
const progress = fs.readFileSync(PROGRESS_PATH, 'utf8');
const lines = progress.split('\n');
// Parse learner name
const nameLine = lines.find(l => l.startsWith('**Learner:**'));
const name = nameLine ? nameLine.replace('**Learner:**', '').trim() : 'Unknown';
// Parse start date
const startLine = lines.find(l => l.startsWith('**Started:**'));
const started = startLine ? startLine.replace('**Started:**', '').trim() : 'Unknown';
// Parse current module
const currentLine = lines.find(l => l.startsWith('**Current module:**'));
const current = currentLine ? currentLine.replace('**Current module:**', '').trim() : 'Unknown';
// Parse completed modules
const completed = lines.filter(l => l.startsWith('- [x]')).map(l => l.replace('- [x]', '').trim());
const skipped = lines.filter(l => l.includes('skipped')).length;
const total = lines.filter(l => l.match(/^- \[[ x]\]/)).length;
// Build report
const exportDate = new Date().toLocaleDateString('en-US', {
year: 'numeric', month: 'long', day: 'numeric'
});
const report = [
'='.repeat(50),
'ONBOARDING COMPLETION REPORT',
'='.repeat(50),
'',
`Learner: ${name}`,
`Program started: ${started}`,
`Report generated: ${exportDate}`,
`Current module: ${current}`,
'',
'-'.repeat(50),
`PROGRESS: ${completed.length} of ${total} modules complete`,
skipped > 0 ? `(${skipped} skipped)` : '',
'-'.repeat(50),
'',
completed.length > 0 ? 'Completed modules:' : 'No modules completed yet.',
...completed.map(m => ` ✓ ${m}`),
'',
completed.length < total ? `Remaining: ${total - completed.length} module(s) to go.` : 'All modules complete.',
'',
'='.repeat(50),
].filter(l => l !== null).join('\n');
// Write to file
const filename = `onboarding-report-${name.toLowerCase().replace(/\s+/g, '-')}-${Date.now()}.txt`;
const outPath = path.join(ROOT, filename);
fs.writeFileSync(outPath, report);
console.log('\n' + report);
console.log(`\nReport saved to: ${filename}\n`);