@eunjae/il 1.0.0 → 1.1.0

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.
@@ -277,6 +277,21 @@ const resolveGithubToken = async (workspaceRoot) => {
277
277
  //#endregion
278
278
  //#region lib/time.ts
279
279
  const DEFAULT_ZONE = "Europe/Paris";
280
+ const toIsoDate = (value, label) => {
281
+ const date = value.toISODate();
282
+ if (!date) throw new Error(`Failed to generate ${label} date`);
283
+ return date;
284
+ };
285
+ const buildDateRange = (start, end) => {
286
+ const dates = [];
287
+ let cursor = start.startOf("day");
288
+ const final = end.startOf("day");
289
+ while (cursor <= final) {
290
+ dates.push(toIsoDate(cursor, "range"));
291
+ cursor = cursor.plus({ days: 1 });
292
+ }
293
+ return dates;
294
+ };
280
295
  const nowIso = () => {
281
296
  const value = DateTime.now().setZone(DEFAULT_ZONE).toISO();
282
297
  if (!value) throw new Error("Failed to generate timestamp");
@@ -287,6 +302,18 @@ const todayDate = (date) => {
287
302
  if (!value) throw new Error("Failed to generate date");
288
303
  return value;
289
304
  };
305
+ const listDatesForScope = (scope) => {
306
+ const now = DateTime.now().setZone(DEFAULT_ZONE);
307
+ switch (scope) {
308
+ case "today": return [toIsoDate(now, "today")];
309
+ case "yesterday": return [toIsoDate(now.minus({ days: 1 }), "yesterday")];
310
+ case "this_week": return buildDateRange(now.startOf("week"), now.endOf("week"));
311
+ case "last_week": {
312
+ const lastWeek = now.minus({ weeks: 1 });
313
+ return buildDateRange(lastWeek.startOf("week"), lastWeek.endOf("week"));
314
+ }
315
+ }
316
+ };
290
317
 
291
318
  //#endregion
292
319
  //#region lib/pr.ts
@@ -725,9 +752,18 @@ const printLines = (lines) => {
725
752
  }
726
753
  process.stdout.write(`${lines.join("\n")}\n`);
727
754
  };
755
+ const listScopes = [
756
+ "today",
757
+ "yesterday",
758
+ "this_week",
759
+ "last_week"
760
+ ];
728
761
  const isTaskStatus = (value) => {
729
762
  return taskStatuses.includes(value);
730
763
  };
764
+ const isListScope = (value) => {
765
+ return listScopes.includes(value);
766
+ };
731
767
  const isPackageJson = (value) => {
732
768
  return value !== null && typeof value === "object" && "version" in value;
733
769
  };
@@ -801,12 +837,25 @@ program.command("add").description("add a task").argument("[title]", "task title
801
837
  process.stdout.write(`Created ${created.alias} ${created.task.ref} ${created.task.title}\n`);
802
838
  });
803
839
  }));
804
- program.command("list").description("list tasks").argument("[status]", "task status").action(handleAction(async (status, command) => {
840
+ program.command("list").description("list tasks").argument("[status]", "task status or date scope").action(handleAction(async (status, command) => {
805
841
  const workspaceRoot = await resolveWorkspaceFor(true);
806
842
  const aliasLookup = buildAliasLookup(await readAliases(workspaceRoot));
807
- if (status && !isTaskStatus(status)) throw new Error(`Invalid status: ${status}`);
808
- const statuses = status ? [status] : [...taskStatuses];
809
843
  const lines = [];
844
+ if (status && !isTaskStatus(status) && !isListScope(status)) throw new Error(`Invalid status or scope: ${status}`);
845
+ if (status && isListScope(status)) {
846
+ const dates = listDatesForScope(status);
847
+ const tasks = await listAllTasks(workspaceRoot);
848
+ for (const entry of tasks) {
849
+ if (!dates.some((date) => isAssignedOnDate(entry.task, date))) continue;
850
+ const alias = aliasLookup.get(entry.task.id);
851
+ let line = formatTaskListLine(entry.task, alias);
852
+ if (entry.task.metadata.pr?.fetched?.state) line += ` PR:${entry.task.metadata.pr.fetched.state}`;
853
+ lines.push(line);
854
+ }
855
+ printLines(lines);
856
+ return;
857
+ }
858
+ const statuses = status ? [status] : [...taskStatuses];
810
859
  for (const currentStatus of statuses) {
811
860
  const stored = await listTasksByStatus(workspaceRoot, currentStatus);
812
861
  for (const entry of stored) {
@@ -870,14 +919,9 @@ program.command("search").description("search tasks").argument("<query>", "searc
870
919
  return line;
871
920
  }));
872
921
  }));
873
- program.command("today").description("assign or list today tasks").argument("[id]", "task identifier").option("--date <date>", "YYYY-MM-DD").option("-m, --message <message>", "assignment message").action(handleAction(async (identifier, options, command) => {
922
+ program.command("today").description("assign a task for today").argument("<id>", "task identifier").option("--date <date>", "YYYY-MM-DD").option("-m, --message <message>", "assignment message").action(handleAction(async (identifier, options, command) => {
874
923
  const workspaceRoot = await resolveWorkspaceFor(true);
875
924
  const date = todayDate(options.date);
876
- if (!identifier) {
877
- const aliasLookup = buildAliasLookup(await readAliases(workspaceRoot));
878
- printLines((await listAllTasks(workspaceRoot)).filter((stored) => isAssignedOnDate(stored.task, date)).map((stored) => formatTaskListLine(stored.task, aliasLookup.get(stored.task.id))));
879
- return;
880
- }
881
925
  await withWorkspaceLock(workspaceRoot, async () => {
882
926
  const stored = await resolveTask(workspaceRoot, identifier);
883
927
  if (isAssignedOnDate(stored.task, date)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eunjae/il",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "il": "dist/scripts/il.mjs"