exe-watcher 0.2.7 → 0.2.8
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/dist/cli.js +42 -13
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -6730,11 +6730,43 @@ function parseDateRangeFlags(from, to) {
|
|
|
6730
6730
|
return { start, end };
|
|
6731
6731
|
}
|
|
6732
6732
|
|
|
6733
|
+
// src/progressive-backfill.ts
|
|
6734
|
+
var MS_PER_DAY3 = 24 * 60 * 60 * 1e3;
|
|
6735
|
+
var DEFAULT_COLD_START_HISTORY_DAYS = 7;
|
|
6736
|
+
var DEFAULT_PROGRESSIVE_CHUNK_DAYS = 30;
|
|
6737
|
+
function nextLocalMidnight(dateString) {
|
|
6738
|
+
return new Date(
|
|
6739
|
+
parseInt(dateString.slice(0, 4), 10),
|
|
6740
|
+
parseInt(dateString.slice(5, 7), 10) - 1,
|
|
6741
|
+
parseInt(dateString.slice(8, 10), 10) + 1
|
|
6742
|
+
);
|
|
6743
|
+
}
|
|
6744
|
+
function computeProgressiveBackfillStart({
|
|
6745
|
+
lastComputedDate,
|
|
6746
|
+
todayStart,
|
|
6747
|
+
yesterdayEnd,
|
|
6748
|
+
backfillDays,
|
|
6749
|
+
coldStartHistoryDays = DEFAULT_COLD_START_HISTORY_DAYS,
|
|
6750
|
+
progressiveChunkDays = DEFAULT_PROGRESSIVE_CHUNK_DAYS
|
|
6751
|
+
}) {
|
|
6752
|
+
const fullBackfillStart = new Date(todayStart.getTime() - backfillDays * MS_PER_DAY3);
|
|
6753
|
+
if (!lastComputedDate) {
|
|
6754
|
+
const priorHistoryDays = Math.max(coldStartHistoryDays - 1, 0);
|
|
6755
|
+
return new Date(todayStart.getTime() - priorHistoryDays * MS_PER_DAY3);
|
|
6756
|
+
}
|
|
6757
|
+
const gapStart = nextLocalMidnight(lastComputedDate);
|
|
6758
|
+
if (gapStart < fullBackfillStart) return fullBackfillStart;
|
|
6759
|
+
if (yesterdayEnd.getTime() - gapStart.getTime() > progressiveChunkDays * MS_PER_DAY3) {
|
|
6760
|
+
return new Date(yesterdayEnd.getTime() - progressiveChunkDays * MS_PER_DAY3);
|
|
6761
|
+
}
|
|
6762
|
+
return gapStart;
|
|
6763
|
+
}
|
|
6764
|
+
|
|
6733
6765
|
// src/cli.ts
|
|
6734
6766
|
import { createRequire as createRequire2 } from "module";
|
|
6735
6767
|
var require2 = createRequire2(import.meta.url);
|
|
6736
6768
|
var { version } = require2("../package.json");
|
|
6737
|
-
var
|
|
6769
|
+
var MS_PER_DAY4 = 24 * 60 * 60 * 1e3;
|
|
6738
6770
|
var BACKFILL_DAYS = 365;
|
|
6739
6771
|
function toDateString(date) {
|
|
6740
6772
|
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
@@ -7017,7 +7049,7 @@ program.command("status").description("Compact status output (today + week + mon
|
|
|
7017
7049
|
const now = /* @__PURE__ */ new Date();
|
|
7018
7050
|
const todayStart = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
7019
7051
|
const yesterdayEnd = new Date(todayStart.getTime() - 1);
|
|
7020
|
-
const yesterdayStr = toDateString(new Date(todayStart.getTime() -
|
|
7052
|
+
const yesterdayStr = toDateString(new Date(todayStart.getTime() - MS_PER_DAY4));
|
|
7021
7053
|
const isAllProviders = pf === "all";
|
|
7022
7054
|
const dailyCacheScope = buildDailyCacheScopeKey(opts.project, opts.exclude);
|
|
7023
7055
|
const cache = await withDailyCacheLock(async () => {
|
|
@@ -7028,16 +7060,13 @@ program.command("status").description("Compact status output (today + week + mon
|
|
|
7028
7060
|
const latestFresh = freshDays.length > 0 ? freshDays[freshDays.length - 1].date : null;
|
|
7029
7061
|
c = { ...c, days: freshDays, lastComputedDate: latestFresh };
|
|
7030
7062
|
}
|
|
7031
|
-
const
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
const fullBackfillStart = new Date(todayStart.getTime() - BACKFILL_DAYS * MS_PER_DAY3);
|
|
7039
|
-
const effectiveGapStart = isColdStart ? todayStart : gapStart < fullBackfillStart ? fullBackfillStart : yesterdayEnd.getTime() - gapStart.getTime() > PROGRESSIVE_CHUNK_DAYS * MS_PER_DAY3 ? new Date(yesterdayEnd.getTime() - PROGRESSIVE_CHUNK_DAYS * MS_PER_DAY3) : gapStart;
|
|
7040
|
-
if (!isColdStart && effectiveGapStart.getTime() <= yesterdayEnd.getTime()) {
|
|
7063
|
+
const effectiveGapStart = computeProgressiveBackfillStart({
|
|
7064
|
+
lastComputedDate: c.lastComputedDate,
|
|
7065
|
+
todayStart,
|
|
7066
|
+
yesterdayEnd,
|
|
7067
|
+
backfillDays: BACKFILL_DAYS
|
|
7068
|
+
});
|
|
7069
|
+
if (effectiveGapStart.getTime() <= yesterdayEnd.getTime()) {
|
|
7041
7070
|
const gapRange = { start: effectiveGapStart, end: yesterdayEnd };
|
|
7042
7071
|
const gapProjects = filterProjectsByName(await parseAllSessions(gapRange, "all"), opts.project, opts.exclude);
|
|
7043
7072
|
const gapDays = fillMissingDays(gapRange.start, gapRange.end, aggregateProjectsIntoDays(gapProjects));
|
|
@@ -7116,7 +7145,7 @@ program.command("status").description("Compact status output (today + week + mon
|
|
|
7116
7145
|
const display = displayNameByName.get(pf) ?? pf;
|
|
7117
7146
|
providers.push({ name: display, cost: currentData.cost });
|
|
7118
7147
|
}
|
|
7119
|
-
const historyStartStr = toDateString(new Date(todayStart.getTime() - BACKFILL_DAYS *
|
|
7148
|
+
const historyStartStr = toDateString(new Date(todayStart.getTime() - BACKFILL_DAYS * MS_PER_DAY4));
|
|
7120
7149
|
const allCacheDays = getDaysInRange(cache, historyStartStr, yesterdayStr);
|
|
7121
7150
|
const fullHistory = [...allCacheDays, ...todayDays.filter((d) => d.date > yesterdayStr)];
|
|
7122
7151
|
const dailyHistory = fullHistory.map((d) => {
|