@@ -13,7 +13,7 @@ import { printFlagList } from '../utils/formatting'
13
13
import { getDefaultKey , setupSdk } from '../utils/sdk'
14
14
15
15
import type { CliSubcommand } from '../utils/meow-with-subcommands'
16
- import type { Ora } from 'ora '
16
+ import { AuthError } from '../utils/errors '
17
17
18
18
export const dependencies : CliSubcommand = {
19
19
description :
@@ -23,9 +23,7 @@ export const dependencies: CliSubcommand = {
23
23
24
24
const input = setupCommand ( name , dependencies . description , argv , importMeta )
25
25
if ( input ) {
26
- const spinnerText = 'Searching dependencies...'
27
- const spinner = ora ( spinnerText ) . start ( )
28
- await searchDeps ( input , spinner )
26
+ await searchDeps ( input )
29
27
}
30
28
}
31
29
}
@@ -100,10 +98,17 @@ function setupCommand(
100
98
}
101
99
102
100
async function searchDeps (
103
- { limit, offset, outputJson } : CommandContext ,
104
- spinner : Ora
101
+ { limit, offset, outputJson } : CommandContext
105
102
) : 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
+
107
112
const result = await handleApiCall (
108
113
socketSdk . searchDependencies ( { limit, offset } ) ,
109
114
'Searching dependencies'
0 commit comments