@controlfront/detect 0.0.2 → 0.0.4
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 +4 -4
- package/src/config/baseUrl.js +11 -0
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");
|
|
@@ -569,8 +569,8 @@ async function postSnapshotDirect({
|
|
|
569
569
|
overwrite = false,
|
|
570
570
|
progressInfo = null,
|
|
571
571
|
}) {
|
|
572
|
-
if (!projectId) {
|
|
573
|
-
throw new Error("CF_PROJECT_ID is required
|
|
572
|
+
if (!projectId && !ingestToken) {
|
|
573
|
+
throw new Error("CF_PROJECT_ID is required when not using an ingest token");
|
|
574
574
|
}
|
|
575
575
|
if (!appUrl) {
|
|
576
576
|
throw new Error("CF_APP_URL or NEXT_PUBLIC_APP_URL is required in CI mode");
|
package/src/config/baseUrl.js
CHANGED
|
@@ -14,6 +14,11 @@ dotenv.config({
|
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
export function getStoredEnvironment() {
|
|
17
|
+
// Explicit env var takes highest priority
|
|
18
|
+
if (process.env.CF_ENV) {
|
|
19
|
+
return process.env.CF_ENV === "prod" ? "prod" : "dev";
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
try {
|
|
18
23
|
const configPath = path.join(os.homedir(), ".cf", "config.json");
|
|
19
24
|
if (fs.existsSync(configPath)) {
|
|
@@ -23,6 +28,12 @@ export function getStoredEnvironment() {
|
|
|
23
28
|
} catch (e) {
|
|
24
29
|
// ignore errors
|
|
25
30
|
}
|
|
31
|
+
|
|
32
|
+
// In CI environments (e.g. GitHub Actions) with no local config, default to prod
|
|
33
|
+
if (process.env.CI) {
|
|
34
|
+
return "prod";
|
|
35
|
+
}
|
|
36
|
+
|
|
26
37
|
return "dev";
|
|
27
38
|
}
|
|
28
39
|
|