Skip to content

Commit 86feada

Browse files
committed
polish; org as alias for defaultOrg, hide json command, drop "default" from banner, add socket org deps alias
1 parent 46bb92e commit 86feada

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

src/commands/json/cmd-json.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const config: CliCommandConfig = {
1010
commandName: 'json',
1111
description:
1212
'Display the `socket.json` that would be applied for target folder',
13-
hidden: false,
13+
hidden: true,
1414
flags: {
1515
...commonFlags,
1616
},

src/commands/organization/cmd-organization.mts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ export const cmdOrganization: CliSubcommand = {
2323
},
2424
{
2525
aliases: {
26+
deps: {
27+
description: cmdOrganizationDependencies.description,
28+
hidden: true,
29+
argv: ['dependencies'],
30+
},
2631
license: {
2732
description: cmdOrganizationPolicyLicense.description,
2833
hidden: true,
@@ -36,7 +41,6 @@ export const cmdOrganization: CliSubcommand = {
3641
},
3742
argv,
3843
description,
39-
defaultSub: 'list', // Backwards compat
4044
importMeta,
4145
name: parentName + ' organization',
4246
},

src/utils/config.mts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

2526
export 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

4143
function 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

8993
export 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
}

src/utils/meow-with-subcommands.mts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ export async function meowWithSubcommands(
252252
'analytics',
253253
'audit-log',
254254
'config',
255-
'dependencies',
256255
'fix',
257256
'install',
258257
'login',
@@ -529,7 +528,7 @@ function getAsciiHeader(command: string) {
529528
const body = `
530529
_____ _ _ /---------------
531530
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver ${cliVersion}
532-
|__ | ${readOnlyConfig} | _| '_| -_| _| | Node: ${nodeVersion}, API token set: ${shownToken}${defaultOrg ? `, default org: ${redacting ? REDACTED : defaultOrg}` : ''}
531+
|__ | ${readOnlyConfig} | _| '_| -_| _| | Node: ${nodeVersion}, API token set: ${shownToken}${defaultOrg ? `, org: ${redacting ? REDACTED : defaultOrg}` : ''}
533532
|_____|___|___|_,_|___|_|.dev | Command: \`${command}\`, cwd: ${relCwd}`.trimStart()
534533

535534
return ` ${body}\n${nodeVerWarn}`

0 commit comments

Comments
 (0)