@@ -13,7 +13,7 @@ import { printFlagList } from '../utils/formatting'
1313import { getDefaultKey , setupSdk } from '../utils/sdk'
1414
1515import type { CliSubcommand } from '../utils/meow-with-subcommands'
16- import type { Ora } from 'ora '
16+ import { AuthError } from '../utils/errors '
1717
1818export const dependencies : CliSubcommand = {
1919 description :
@@ -23,9 +23,7 @@ export const dependencies: CliSubcommand = {
2323
2424 const input = setupCommand ( name , dependencies . description , argv , importMeta )
2525 if ( input ) {
26- const spinnerText = 'Searching dependencies...'
27- const spinner = ora ( spinnerText ) . start ( )
28- await searchDeps ( input , spinner )
26+ await searchDeps ( input )
2927 }
3028 }
3129}
@@ -100,10 +98,17 @@ function setupCommand(
10098}
10199
102100async function searchDeps (
103- { limit, offset, outputJson } : CommandContext ,
104- spinner : Ora
101+ { limit, offset, outputJson } : CommandContext
105102) : Promise < void > {
106- const socketSdk = await setupSdk ( getDefaultKey ( ) )
103+ const apiKey = getDefaultKey ( )
104+ if ( ! apiKey ) {
105+ throw new AuthError ( "User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key." )
106+ }
107+ const spinnerText = 'Searching dependencies...'
108+ const spinner = ora ( spinnerText ) . start ( )
109+
110+ const socketSdk = await setupSdk ( apiKey )
111+
107112 const result = await handleApiCall (
108113 socketSdk . searchDependencies ( { limit, offset } ) ,
109114 'Searching dependencies'
0 commit comments