@chatlane/cli 0.1.0 → 0.1.1
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/logout.js +2 -1
- package/src/runtime.js +15 -5
package/package.json
CHANGED
package/src/commands/logout.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { updateConfig } from '../config.js'
|
|
2
|
+
import { DEFAULT_API_BASE_URL } from '../constants.js'
|
|
2
3
|
import { logoutHelp } from '../help-text.js'
|
|
3
4
|
import { ensureNoExtraArgs } from './utils.js'
|
|
4
5
|
|
|
@@ -6,6 +7,6 @@ export async function runLogout(args, ctx) {
|
|
|
6
7
|
const handled = ensureNoExtraArgs(args, logoutHelp(), ctx.print)
|
|
7
8
|
if (handled) return
|
|
8
9
|
|
|
9
|
-
updateConfig({ token: null })
|
|
10
|
+
updateConfig({ token: null, apiBaseUrl: DEFAULT_API_BASE_URL })
|
|
10
11
|
ctx.print('Logged out.')
|
|
11
12
|
}
|
package/src/runtime.js
CHANGED
|
@@ -7,11 +7,21 @@ import {
|
|
|
7
7
|
} from './constants.js'
|
|
8
8
|
|
|
9
9
|
export function getApiBaseUrl() {
|
|
10
|
-
|
|
11
|
-
process.env.CHATLANE_API_URL
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
).replace(/\/+$/, '')
|
|
10
|
+
const envBaseUrl =
|
|
11
|
+
typeof process.env.CHATLANE_API_URL === 'string'
|
|
12
|
+
? process.env.CHATLANE_API_URL.trim()
|
|
13
|
+
: ''
|
|
14
|
+
if (envBaseUrl) return envBaseUrl.replace(/\/+$/, '')
|
|
15
|
+
|
|
16
|
+
const config = readConfig()
|
|
17
|
+
const hasStoredToken =
|
|
18
|
+
typeof config.token === 'string' && Boolean(config.token.trim())
|
|
19
|
+
const configBaseUrl =
|
|
20
|
+
typeof config.apiBaseUrl === 'string' ? config.apiBaseUrl.trim() : ''
|
|
21
|
+
|
|
22
|
+
// Keep token+baseURL pairs together; logged-out config should default to prod.
|
|
23
|
+
if (hasStoredToken && configBaseUrl) return configBaseUrl.replace(/\/+$/, '')
|
|
24
|
+
return DEFAULT_API_BASE_URL
|
|
15
25
|
}
|
|
16
26
|
|
|
17
27
|
export function getClientId() {
|