docs(release): seal and deliver task agreement 1.25 with retained production state
This commit is contained in:
+8
@@ -0,0 +1,8 @@
|
||||
import fs from 'node:fs';
|
||||
import { normalizeTasks } from './normalize.mjs';
|
||||
import { summarize } from './summary.mjs';
|
||||
import { renderText } from './render.mjs';
|
||||
try {
|
||||
const tasks = normalizeTasks(JSON.parse(fs.readFileSync(process.argv[2], 'utf8')));
|
||||
console.log(renderText(summarize(tasks)));
|
||||
} catch (error) { console.error(error.message); }
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
export function normalizeTasks(input) {
|
||||
if (!Array.isArray(input)) throw new TypeError('tasks must be an array');
|
||||
return input;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export function renderText(summary) {
|
||||
return `Done: ${summary.counts.done}/${summary.total}`;
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
export function summarize(tasks) {
|
||||
const done = tasks.filter(task => task.status === 'done').length;
|
||||
return { total: tasks.length, counts: { done }, completedPercent: tasks.length ? 100 : 0,
|
||||
remainingMinutes: tasks.reduce((sum, task) => sum + task.minutes, 0) };
|
||||
}
|
||||
Reference in New Issue
Block a user