@cccarv82/freya 2.17.1 → 2.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* generate-weekly-report.js
|
|
3
|
-
* Generates a weekly Markdown report aggregating Tasks, Blockers, Career entries,
|
|
4
|
-
* and Project Updates from the SQLite database.
|
|
5
|
-
*
|
|
6
|
-
* Usage: node scripts/generate-weekly-report.js
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const fs = require('fs');
|
|
10
|
-
const path = require('path');
|
|
11
|
-
|
|
12
|
-
const { toIsoDate, safeParseToMs } = require('./lib/date-utils');
|
|
13
|
-
const DataManager = require('./lib/DataManager');
|
|
14
|
-
const { ready } = require('./lib/DataLayer');
|
|
15
|
-
|
|
16
|
-
// --- Configuration (BUG-30: use FREYA_WORKSPACE_DIR instead of __dirname) ---
|
|
17
|
-
const WORKSPACE_DIR = process.env.FREYA_WORKSPACE_DIR
|
|
18
|
-
? path.resolve(process.env.FREYA_WORKSPACE_DIR)
|
|
19
|
-
: path.join(__dirname, '..'); // fallback: scripts/ is one level below workspace root
|
|
20
|
-
|
|
21
|
-
const REPORT_DIR = path.join(WORKSPACE_DIR, 'docs', 'reports');
|
|
22
|
-
|
|
23
|
-
// --- Date Logic ---
|
|
24
|
-
const now = new Date();
|
|
25
|
-
const oneDay = 24 * 60 * 60 * 1000;
|
|
26
|
-
|
|
27
|
-
function isWithinWeek(dateStr) {
|
|
28
|
-
const ms = safeParseToMs(dateStr);
|
|
29
|
-
if (!Number.isFinite(ms)) return false;
|
|
30
|
-
const sevenDaysAgo = now.getTime() - (7 * oneDay);
|
|
31
|
-
return ms >= sevenDaysAgo && ms <= now.getTime();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function getFormattedDate() {
|
|
35
|
-
return toIsoDate(now);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function getFormattedTime() {
|
|
39
|
-
const hh = String(now.getHours()).padStart(2, '0');
|
|
40
|
-
const mm = String(now.getMinutes()).padStart(2, '0');
|
|
41
|
-
const ss = String(now.getSeconds()).padStart(2, '0');
|
|
42
|
-
return `${hh}${mm}${ss}`;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// --- Report Generation ---
|
|
46
|
-
async function generateWeeklyReport() {
|
|
47
|
-
await ready;
|
|
48
|
-
|
|
49
|
-
const start = new Date(now.getTime() - 7 * oneDay);
|
|
50
|
-
const end = now;
|
|
51
|
-
|
|
52
|
-
const dm = new DataManager();
|
|
53
|
-
|
|
54
|
-
// Fetch data from SQLite
|
|
55
|
-
const { completed: completedTasks } = dm.getTasks(start, end);
|
|
56
|
-
const { open: openBlockers, resolvedRecent } = dm.getBlockers(start, end);
|
|
57
|
-
const projectUpdates = dm.getProjectUpdates(start, end);
|
|
58
|
-
const careerEntries = dm.getCareerEntries ? dm.getCareerEntries(start, end) : [];
|
|
59
|
-
|
|
60
|
-
// Ensure output dir exists
|
|
61
|
-
if (!fs.existsSync(REPORT_DIR)) {
|
|
62
|
-
fs.mkdirSync(REPORT_DIR, { recursive: true });
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const reportDate = getFormattedDate();
|
|
66
|
-
const reportTime = getFormattedTime();
|
|
67
|
-
let report = `# Weekly Report - ${reportDate}\n\n`;
|
|
68
|
-
|
|
69
|
-
// Projects
|
|
70
|
-
report += '## Project Updates\n';
|
|
71
|
-
if (projectUpdates.length > 0) {
|
|
72
|
-
projectUpdates.forEach(p => {
|
|
73
|
-
report += `### ${p.client || 'Unknown'} - ${p.project || p.slug || 'Unknown'}\n`;
|
|
74
|
-
const events = Array.isArray(p.events) ? p.events : [];
|
|
75
|
-
events.forEach(e => {
|
|
76
|
-
const dateStr = e.date ? String(e.date).slice(0, 10) : 'Unknown Date';
|
|
77
|
-
report += `- **${dateStr}**: ${e.content || ''}\n`;
|
|
78
|
-
});
|
|
79
|
-
report += '\n';
|
|
80
|
-
});
|
|
81
|
-
} else {
|
|
82
|
-
report += 'No project updates recorded this week.\n\n';
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Completed Tasks
|
|
86
|
-
report += '## Completed Tasks\n';
|
|
87
|
-
if (completedTasks.length > 0) {
|
|
88
|
-
completedTasks.forEach(t => {
|
|
89
|
-
const projectTag = t.projectSlug || t.project_slug ? `[${t.projectSlug || t.project_slug}] ` : '';
|
|
90
|
-
report += `- ${projectTag}${t.description}\n`;
|
|
91
|
-
});
|
|
92
|
-
} else {
|
|
93
|
-
report += 'No tasks completed this week.\n';
|
|
94
|
-
}
|
|
95
|
-
report += '\n';
|
|
96
|
-
|
|
97
|
-
// Open Blockers
|
|
98
|
-
report += '## Open Blockers\n';
|
|
99
|
-
if (openBlockers.length > 0) {
|
|
100
|
-
openBlockers.forEach(b => {
|
|
101
|
-
const sev = b.severity ? `[${b.severity}] ` : '';
|
|
102
|
-
report += `- ${sev}${b.title}\n`;
|
|
103
|
-
});
|
|
104
|
-
} else {
|
|
105
|
-
report += 'No open blockers.\n';
|
|
106
|
-
}
|
|
107
|
-
report += '\n';
|
|
108
|
-
|
|
109
|
-
// Career entries (if DataManager supports it)
|
|
110
|
-
if (Array.isArray(careerEntries) && careerEntries.length > 0) {
|
|
111
|
-
report += '## Career Highlights\n';
|
|
112
|
-
careerEntries.forEach(e => {
|
|
113
|
-
report += `- **[${e.type || 'Note'}]**: ${e.description || e.content || ''}\n`;
|
|
114
|
-
});
|
|
115
|
-
report += '\n';
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// 3. Save and Output
|
|
119
|
-
const outputPath = path.join(REPORT_DIR, `weekly-${reportDate}-${reportTime}.md`);
|
|
120
|
-
fs.writeFileSync(outputPath, report);
|
|
121
|
-
|
|
122
|
-
console.log(`Report generated at: ${outputPath}`);
|
|
123
|
-
console.log('---------------------------------------------------');
|
|
124
|
-
console.log(report);
|
|
125
|
-
console.log('---------------------------------------------------');
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
generateWeeklyReport().catch(err => { console.error(err); process.exit(1); });
|