11import type { Logger } from "@base44-cli/logger" ;
22import pWaitFor from "p-wait-for" ;
33import type { CLIContext , RunCommandResult } from "@/cli/types.js" ;
4- import { runTask } from "@/cli/utils/index .js" ;
4+ import type { RunTaskFn } from "@/cli/utils/runTask .js" ;
55import { theme } from "@/cli/utils/theme.js" ;
66import type {
77 DeviceCodeResponse ,
@@ -18,6 +18,7 @@ import { AuthExpiredError, InternalError } from "@/core/errors.js";
1818
1919async function generateAndDisplayDeviceCode (
2020 log : Logger ,
21+ runTask : RunTaskFn ,
2122) : Promise < DeviceCodeResponse > {
2223 const deviceCodeResponse = await runTask (
2324 "Generating device code..." ,
@@ -42,6 +43,7 @@ async function waitForAuthentication(
4243 deviceCode : string ,
4344 expiresIn : number ,
4445 interval : number ,
46+ runTask : RunTaskFn ,
4547) : Promise < TokenResponse > {
4648 let tokenResponse : TokenResponse | undefined ;
4749
@@ -102,13 +104,17 @@ async function saveAuthData(
102104 * Execute the login flow (device code authentication).
103105 * This function is separate from the command to avoid circular dependencies.
104106 */
105- export async function login ( { log } : CLIContext ) : Promise < RunCommandResult > {
106- const deviceCodeResponse = await generateAndDisplayDeviceCode ( log ) ;
107+ export async function login ( {
108+ log,
109+ runTask,
110+ } : CLIContext ) : Promise < RunCommandResult > {
111+ const deviceCodeResponse = await generateAndDisplayDeviceCode ( log , runTask ) ;
107112
108113 const token = await waitForAuthentication (
109114 deviceCodeResponse . deviceCode ,
110115 deviceCodeResponse . expiresIn ,
111116 deviceCodeResponse . interval ,
117+ runTask ,
112118 ) ;
113119
114120 const userInfo = await getUserInfo ( token . accessToken ) ;
0 commit comments