77 saveAuthToken ,
88 readAuthToken ,
99} from "../utils/authenticate.ts" ;
10+ import { findLocalStack } from "../utils/cli.ts" ;
1011import { configureAwsProfiles } from "../utils/configure-aws.ts" ;
1112import { runInstallProcess } from "../utils/install.ts" ;
1213import {
@@ -18,6 +19,14 @@ import { minDelay } from "../utils/promises.ts";
1819import { updateDockerImage } from "../utils/setup.ts" ;
1920import { get_setup_ended } from "../utils/telemetry.ts" ;
2021
22+ async function getValidCliPath ( ) {
23+ const cli = await findLocalStack ( )
24+ if ( ! cli . cliPath || ! cli . executable || ! cli . found || ! cli . upToDate ) {
25+ return
26+ }
27+ return cli . cliPath
28+ }
29+
2130export default createPlugin (
2231 "setup" ,
2332 ( {
@@ -225,10 +234,14 @@ export default createPlugin(
225234 /////////////////////////////////////////////////////////////////////
226235 progress . report ( { message : "Checking LocalStack license..." } ) ;
227236
228- const cliPath = cliStatusTracker . cliPath ( ) ;
237+ // If the CLI status tracker doesn't have a valid CLI path yet,
238+ // we must find it manually. This may occur when installing the
239+ // CLI as part of the setup process: the CLI status tracker will
240+ // detect the CLI path the next tick.
241+ const cliPath = cliStatusTracker . cliPath ( ) ?? await getValidCliPath ( ) ;
229242 if ( ! cliPath ) {
230243 void window . showErrorMessage (
231- "LocalStack CLI is not configured. Please set it up before running the setup wizard ." ,
244+ "Could not access the LocalStack CLI ." ,
232245 ) ;
233246 return ;
234247 }
0 commit comments