@@ -20,6 +20,7 @@ export interface LocalConfig {
20
20
apiToken ?: string | null | undefined
21
21
defaultOrg ?: string
22
22
enforcedOrgs ?: string [ ] | readonly string [ ] | null | undefined
23
+ org ?: string // convenience alias for defaultOrg
23
24
}
24
25
25
26
export const sensitiveConfigKeys : Set < keyof LocalConfig > = new Set ( [ 'apiToken' ] )
@@ -36,6 +37,7 @@ export const supportedConfigKeys: Map<keyof LocalConfig, string> = new Map([
36
37
'enforcedOrgs' ,
37
38
'Orgs in this list have their security policies enforced on this machine' ,
38
39
] ,
40
+ [ 'org' , 'Alias for defaultOrg' ] ,
39
41
] )
40
42
41
43
function getConfigValues ( ) : LocalConfig {
@@ -75,15 +77,17 @@ function normalizeConfigKey(
75
77
) : CResult < keyof LocalConfig > {
76
78
// Note: apiKey was the old name of the token. When we load a config with
77
79
// property apiKey, we'll copy that to apiToken and delete the old property.
78
- const normalizedKey = key === 'apiKey' ? 'apiToken' : key
80
+ // We added `org` as a convenience alias for `defaultOrg`
81
+ const normalizedKey =
82
+ key === 'apiKey' ? 'apiToken' : key === 'org' ? 'defaultOrg' : key
79
83
if ( ! supportedConfigKeys . has ( normalizedKey ) ) {
80
84
return {
81
85
ok : false ,
82
86
message : `Invalid config key: ${ normalizedKey } ` ,
83
87
data : undefined ,
84
88
}
85
89
}
86
- return { ok : true , data : key }
90
+ return { ok : true , data : normalizedKey }
87
91
}
88
92
89
93
export function findSocketYmlSync ( dir = process . cwd ( ) ) {
@@ -175,7 +179,7 @@ export function overrideCachedConfig(jsonConfig: unknown): CResult<undefined> {
175
179
_cachedConfig = config as LocalConfig
176
180
_readOnlyConfig = true
177
181
178
- // Normalize apiKey to apiToken.
182
+ // Normalize apiKey to apiToken
179
183
if ( _cachedConfig [ 'apiKey' ] ) {
180
184
if ( _cachedConfig [ 'apiToken' ] ) {
181
185
logger . warn (
@@ -214,7 +218,7 @@ export function updateConfigValue<Key extends keyof LocalConfig>(
214
218
if ( _readOnlyConfig ) {
215
219
return {
216
220
ok : true ,
217
- message : `Config key '${ key } ' was updated` ,
221
+ message : `Config key '${ keyResult . data } ' was updated` ,
218
222
data : 'Change applied but not persisted; current config is overridden through env var or flag' ,
219
223
}
220
224
}
@@ -236,7 +240,7 @@ export function updateConfigValue<Key extends keyof LocalConfig>(
236
240
237
241
return {
238
242
ok : true ,
239
- message : `Config key '${ key } ' was updated` ,
243
+ message : `Config key '${ keyResult . data } ' was updated` ,
240
244
data : undefined ,
241
245
}
242
246
}
0 commit comments