Skip to content

Commit

Permalink
Hide fix command
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Jan 21, 2025
1 parent 1e03883 commit c1aefcb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ import { meowWithSubcommands } from './utils/meow-with-subcommands'
const { rootPkgJsonPath } = constants

const formattedCliCommands = Object.fromEntries(
Object.entries(cliCommands).map(entry => {
const key = entry[0]
entry[0] = camelToHyphen(key)
return entry
})
Object.entries(cliCommands)
.map(entry => {
const key = entry[0]
entry[0] = camelToHyphen(key)
return entry
})
)

function camelToHyphen(str: string): string {
Expand Down
1 change: 1 addition & 0 deletions src/commands/fix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const { SOCKET_CLI_FIX_PACKAGE_LOCK_FILE, SOCKET_IPC_HANDSHAKE } = constants

export const fix: CliSubcommand = {
description: 'Fix "fixable" Socket alerts',
hidden: true,
async run() {
const spinner = new Spinner().start()
try {
Expand Down
15 changes: 13 additions & 2 deletions src/utils/meow-with-subcommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type CliSubcommandRun = (

export interface CliSubcommand {
description: string
hidden?: boolean
run: CliSubcommandRun
}

Expand Down Expand Up @@ -72,8 +73,18 @@ export async function meowWithSubcommands(
Commands
${getHelpListOutput(
{
...toSortedObject(subcommands),
...toSortedObject(aliases)
...toSortedObject(
Object.fromEntries(
Object.entries(subcommands)
.filter(entry => !entry[1].hidden)
)
),
...toSortedObject(
Object.fromEntries(
Object.entries(aliases)
.filter(entry => !subcommands[entry[1]?.argv[0]!]?.hidden)
)
)
},
6
)}
Expand Down

0 comments on commit c1aefcb

Please sign in to comment.