reslop 0.1.6 → 0.1.7

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/lib/review.js CHANGED
@@ -3,7 +3,7 @@
3
3
  const fs = require('node:fs');
4
4
  const path = require('node:path');
5
5
 
6
- const { itemPath, REVIEW_DIR } = require('./files.js');
6
+ const { REVIEW_DIR, TODO_FILE } = require('./files.js');
7
7
 
8
8
  const TEMPLATES_FILE = 'templates.json';
9
9
  const TEMPLATE_SHOW = 5;
@@ -179,10 +179,12 @@ const createStore = (reviewPath, templates = []) => ({
179
179
  });
180
180
 
181
181
  const noteCounts = (store) => {
182
- const counts = { feedback: 0, todo: 0, code: 0 };
182
+ const counts = { feedback: 0, todo: 0, todoDone: 0, code: 0 };
183
183
  if (!store) return counts;
184
184
  for (const todo of store.todos) {
185
- if (todo.text.trim()) counts.todo += 1;
185
+ if (!todo.text.trim()) continue;
186
+ counts.todo += 1;
187
+ if (todo.done) counts.todoDone += 1;
186
188
  }
187
189
  for (const note of store.feedback.values()) {
188
190
  if (note.text.trim()) counts.feedback += 1;
@@ -420,7 +422,7 @@ const groupReviewNotes = (store) => {
420
422
  const groups = new Map();
421
423
  for (const todo of store.todos) {
422
424
  if (!todo.text.trim()) continue;
423
- fileGroup(groups, todo.file).todos.push(todo);
425
+ fileGroup(groups, TODO_FILE).todos.push(todo);
424
426
  }
425
427
  for (const key of store.feedback.keys()) {
426
428
  const note = store.feedback.get(key);
@@ -746,64 +748,6 @@ const flushReview = (store, io = {}) => {
746
748
  return true;
747
749
  };
748
750
 
749
- const todosByFile = (todos) => {
750
- const byFile = new Map();
751
- for (const todo of todos) {
752
- const list = byFile.get(todo.file);
753
- if (list) list.push(todo);
754
- else byFile.set(todo.file, [todo]);
755
- }
756
- return byFile;
757
- };
758
-
759
- const makeTodoItem = (file) => ({
760
- origin: 'todo',
761
- file: {
762
- oldPath: file,
763
- newPath: file,
764
- isNew: false,
765
- isDeleted: false,
766
- isBinary: false,
767
- preamble: [],
768
- hunks: [],
769
- },
770
- hunk: null,
771
- blockId: 'todo',
772
- patchAdd: '',
773
- patchRevert: '',
774
- });
775
-
776
- const mergeTodos = (gitItems, todos, extraFiles = []) => {
777
- const base = gitItems.filter((item) => item.origin !== 'todo');
778
- const byFile = todosByFile(todos);
779
- for (const file of extraFiles) {
780
- if (!file || byFile.has(file)) continue;
781
- byFile.set(file, []);
782
- }
783
- if (!byFile.size) return base;
784
- const out = [];
785
- const placed = new Set();
786
- const placePage = (rel) => {
787
- if (placed.has(rel)) return;
788
- if (!byFile.has(rel)) return;
789
- placed.add(rel);
790
- out.push(makeTodoItem(rel));
791
- };
792
- for (let i = 0; i < base.length; i++) {
793
- const item = base[i];
794
- const rel = itemPath(item);
795
- const prev = base[i - 1];
796
- const prevRel = prev ? itemPath(prev) : '';
797
- if (rel !== prevRel) placePage(rel);
798
- out.push(item);
799
- }
800
- for (const rel of byFile.keys()) {
801
- if (placed.has(rel)) continue;
802
- placePage(rel);
803
- }
804
- return out;
805
- };
806
-
807
751
  module.exports = {
808
752
  TEMPLATE_SHOW,
809
753
  AUTOSAVE_MS,
@@ -832,5 +776,4 @@ module.exports = {
832
776
  loadReview,
833
777
  loadTemplates,
834
778
  flushReview,
835
- mergeTodos,
836
779
  };