@@ -20,6 +20,7 @@ export interface LocalConfig {
2020 apiToken ?: string | null | undefined
2121 defaultOrg ?: string
2222 enforcedOrgs ?: string [ ] | readonly string [ ] | null | undefined
23+ org ?: string // convenience alias for defaultOrg
2324}
2425
2526export const sensitiveConfigKeys : Set < keyof LocalConfig > = new Set ( [ 'apiToken' ] )
@@ -36,6 +37,7 @@ export const supportedConfigKeys: Map<keyof LocalConfig, string> = new Map([
3637 'enforcedOrgs' ,
3738 'Orgs in this list have their security policies enforced on this machine' ,
3839 ] ,
40+ [ 'org' , 'Alias for defaultOrg' ] ,
3941] )
4042
4143function getConfigValues ( ) : LocalConfig {
@@ -75,15 +77,17 @@ function normalizeConfigKey(
7577) : CResult < keyof LocalConfig > {
7678 // Note: apiKey was the old name of the token. When we load a config with
7779 // 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
7983 if ( ! supportedConfigKeys . has ( normalizedKey ) ) {
8084 return {
8185 ok : false ,
8286 message : `Invalid config key: ${ normalizedKey } ` ,
8387 data : undefined ,
8488 }
8589 }
86- return { ok : true , data : key }
90+ return { ok : true , data : normalizedKey }
8791}
8892
8993export function findSocketYmlSync ( dir = process . cwd ( ) ) {
@@ -175,7 +179,7 @@ export function overrideCachedConfig(jsonConfig: unknown): CResult<undefined> {
175179 _cachedConfig = config as LocalConfig
176180 _readOnlyConfig = true
177181
178- // Normalize apiKey to apiToken.
182+ // Normalize apiKey to apiToken
179183 if ( _cachedConfig [ 'apiKey' ] ) {
180184 if ( _cachedConfig [ 'apiToken' ] ) {
181185 logger . warn (
@@ -214,7 +218,7 @@ export function updateConfigValue<Key extends keyof LocalConfig>(
214218 if ( _readOnlyConfig ) {
215219 return {
216220 ok : true ,
217- message : `Config key '${ key } ' was updated` ,
221+ message : `Config key '${ keyResult . data } ' was updated` ,
218222 data : 'Change applied but not persisted; current config is overridden through env var or flag' ,
219223 }
220224 }
@@ -236,7 +240,7 @@ export function updateConfigValue<Key extends keyof LocalConfig>(
236240
237241 return {
238242 ok : true ,
239- message : `Config key '${ key } ' was updated` ,
243+ message : `Config key '${ keyResult . data } ' was updated` ,
240244 data : undefined ,
241245 }
242246}
0 commit comments