Skip to content

Commit d8b9f57

Browse files
authored
feat(cli): warn if env vars override values from "auth --login" (#548)
1 parent 37451fe commit d8b9f57

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

.changeset/dry-items-applaud.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"lingo.dev": patch
3+
---
4+
5+
warn if env vars override values from "auth --login"

packages/cli/src/cli/utils/settings.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export function getSettings(explicitApiKey: string | undefined): CliSettings {
1414

1515
_legacyEnvVarWarning();
1616

17+
_envVarsWarning();
18+
1719
return {
1820
auth: {
1921
apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || systemFile.auth?.apiKey || defaults.auth.apiKey,
@@ -102,3 +104,21 @@ Please use LINGODOTDEV_API_KEY instead.
102104
);
103105
}
104106
}
107+
108+
function _envVarsWarning() {
109+
const env = _loadEnv();
110+
const systemFile = _loadSystemFile();
111+
112+
if (env.LINGODOTDEV_API_KEY && systemFile.auth?.apiKey) {
113+
console.warn(
114+
"\x1b[33m%s\x1b[0m",
115+
`⚠️ WARNING: Using LINGODOTDEV_API_KEY env var instead of credentials from login flow (saved in .lingodotdevrc)`,
116+
);
117+
}
118+
if (env.LINGODOTDEV_API_URL) {
119+
console.warn("\x1b[33m%s\x1b[0m", `⚠️ WARNING: Using LINGODOTDEV_API_URL: ${env.LINGODOTDEV_API_URL}`);
120+
}
121+
if (env.LINGODOTDEV_WEB_URL) {
122+
console.warn("\x1b[33m%s\x1b[0m", `⚠️ WARNING: Using LINGODOTDEV_WEB_URL: ${env.LINGODOTDEV_WEB_URL}`);
123+
}
124+
}

0 commit comments

Comments
 (0)