@controlfront/detect 0.0.3 → 0.0.5
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/package.json +1 -1
- package/src/commands/scan.js +20 -4
package/package.json
CHANGED
package/src/commands/scan.js
CHANGED
|
@@ -512,8 +512,8 @@ async function postBaselineDirect({
|
|
|
512
512
|
targetCommit,
|
|
513
513
|
overwrite = false,
|
|
514
514
|
}) {
|
|
515
|
-
if (!projectId) {
|
|
516
|
-
throw new Error("CF_PROJECT_ID is required
|
|
515
|
+
if (!projectId && !ingestToken) {
|
|
516
|
+
throw new Error("CF_PROJECT_ID is required when not using an ingest token");
|
|
517
517
|
}
|
|
518
518
|
if (!appUrl) {
|
|
519
519
|
throw new Error("CF_APP_URL or NEXT_PUBLIC_APP_URL is required in CI mode");
|
|
@@ -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}`
|
|
@@ -569,8 +577,8 @@ async function postSnapshotDirect({
|
|
|
569
577
|
overwrite = false,
|
|
570
578
|
progressInfo = null,
|
|
571
579
|
}) {
|
|
572
|
-
if (!projectId) {
|
|
573
|
-
throw new Error("CF_PROJECT_ID is required
|
|
580
|
+
if (!projectId && !ingestToken) {
|
|
581
|
+
throw new Error("CF_PROJECT_ID is required when not using an ingest token");
|
|
574
582
|
}
|
|
575
583
|
if (!appUrl) {
|
|
576
584
|
throw new Error("CF_APP_URL or NEXT_PUBLIC_APP_URL is required in CI mode");
|
|
@@ -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}`
|