@controlfront/detect 0.0.4 → 0.0.6

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/bin/cfb.js CHANGED
@@ -46,6 +46,10 @@ program
46
46
  "--last-180-days-all",
47
47
  "Run a snapshot scan for every commit in the last 180 days"
48
48
  )
49
+ .option(
50
+ "--last-14-days-all",
51
+ "Run a snapshot scan for every commit in the last 14 days"
52
+ )
49
53
  .option(
50
54
  "--range-sha <from,to>",
51
55
  "Run a snapshot scan for every commit between two SHAs (inclusive), e.g. --range-sha abc123,def456"
@@ -69,6 +73,7 @@ program
69
73
  const makeBaseline = options.makeBaseline === true;
70
74
  const last90DaysAll = options.last90DaysAll === true;
71
75
  const last180DaysAll = options.last180DaysAll === true;
76
+ const last14DaysAll = options.last14DaysAll === true;
72
77
  const rangeSha = options.rangeSha;
73
78
  const rangeDate = options.rangeDate;
74
79
  const lastCommit = options.lastCommit === true;
@@ -94,7 +99,7 @@ program
94
99
  return;
95
100
  }
96
101
 
97
- if (!snapshot && !options.baseline && !last90DaysAll && !last180DaysAll && !rangeSha && !rangeDate) {
102
+ if (!snapshot && !options.baseline && !last90DaysAll && !last180DaysAll && !last14DaysAll && !rangeSha && !rangeDate) {
98
103
  console.error("❌ You must specify --snapshot or --last-commit.");
99
104
  process.exit(1);
100
105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@controlfront/detect",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -551,6 +551,14 @@ async function postBaselineDirect({
551
551
  }
552
552
  );
553
553
  if (!res.ok) {
554
+ // 409 duplicate means the baseline already exists for this commit — not an error
555
+ if (res.status === 409) {
556
+ const body = await res.json().catch(() => ({}));
557
+ if (body?.code === "duplicate") {
558
+ console.log("ℹ️ Baseline already exists for this commit — skipping (idempotent)");
559
+ return;
560
+ }
561
+ }
554
562
  const text = await res.text().catch(() => "");
555
563
  throw new Error(
556
564
  `Baseline sync failed: ${res.status} ${res.statusText} ${text}`
@@ -606,6 +614,14 @@ async function postSnapshotDirect({
606
614
  body: JSON.stringify(payload),
607
615
  });
608
616
  if (!res.ok) {
617
+ // 409 duplicate means the snapshot already exists for this commit — not an error
618
+ if (res.status === 409) {
619
+ const body = await res.json().catch(() => ({}));
620
+ if (body?.code === "duplicate") {
621
+ console.log("ℹ️ Snapshot already exists for this commit — skipping (idempotent)");
622
+ return;
623
+ }
624
+ }
609
625
  const text = await res.text().catch(() => "");
610
626
  throw new Error(
611
627
  `Snapshot sync failed: ${res.status} ${res.statusText} ${text}`
@@ -833,6 +849,15 @@ export async function runScan({
833
849
  await runBackfill({ days: 180, syncBackfill, slugBackfill });
834
850
  }
835
851
 
852
+ if (!isBackfillChild && !lastCommit && process.argv.includes("--last-14-days-all")) {
853
+ const syncBackfill = process.argv.includes("--sync");
854
+ let slugBackfill;
855
+ for (const arg of process.argv) {
856
+ if (arg.startsWith("--slug=")) slugBackfill = arg.split("=")[1];
857
+ }
858
+ await runBackfill({ days: 14, syncBackfill, slugBackfill });
859
+ }
860
+
836
861
  // --- Backfill over a commit SHA range ---
837
862
  if (
838
863
  !isBackfillChild &&