periderm-cli 0.1.49 → 0.1.53
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/config.js +9 -1
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -3,13 +3,21 @@ import path from "node:path";
|
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
const CONFIG_DIR = path.join(os.homedir(), ".periderm");
|
|
5
5
|
const CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
|
|
6
|
+
const DEFAULT_API_URL = "https://periderm-cli.vercel.app";
|
|
6
7
|
export function resolveApiUrl(stored) {
|
|
7
|
-
return (process.env.PERIDERM_API_URL || stored ||
|
|
8
|
+
return (process.env.PERIDERM_API_URL || stored || DEFAULT_API_URL).replace(/\/$/, "");
|
|
8
9
|
}
|
|
9
10
|
export function readConfig() {
|
|
10
11
|
try {
|
|
11
12
|
if (fs.existsSync(CONFIG_FILE)) {
|
|
12
13
|
const raw = JSON.parse(fs.readFileSync(CONFIG_FILE, "utf8"));
|
|
14
|
+
// Auto-fix corrupted config by clearing out localhost URLs
|
|
15
|
+
// (forces the CLI to use the production default or the explicitly set PERIDERM_API_URL)
|
|
16
|
+
if (raw.apiUrl && !process.env.PERIDERM_API_URL && (raw.apiUrl.includes("localhost") || raw.apiUrl.includes("127.0.0.1"))) {
|
|
17
|
+
console.warn("[periderm] Detected local dev URL in config. Clearing corrupted config...");
|
|
18
|
+
fs.unlinkSync(CONFIG_FILE); // Purge the corrupted file
|
|
19
|
+
return { apiUrl: resolveApiUrl() };
|
|
20
|
+
}
|
|
13
21
|
return { apiUrl: resolveApiUrl(raw.apiUrl), token: raw.token };
|
|
14
22
|
}
|
|
15
23
|
}
|