@@ -21,7 +21,7 @@ import type { TimeTracker } from "./time-tracker.ts";
2121export type SetupStatus = "ok" | "setup_required" ;
2222
2323export interface SetupStatusTracker extends Disposable {
24- status ( ) : SetupStatus | undefined ;
24+ status ( ) : SetupStatus | undefined ;
2525 onChange ( callback : ( status : SetupStatus ) => void ) : void ;
2626}
2727
@@ -39,7 +39,11 @@ export async function createSetupStatusTracker(
3939 const awsProfileTracker = createAwsProfileStatusTracker ( outputChannel ) ;
4040 const localStackAuthenticationTracker =
4141 createLocalStackAuthenticationStatusTracker ( outputChannel ) ;
42- const licenseTracker = createLicenseStatusTracker ( cliTracker , localStackAuthenticationTracker , outputChannel ) ;
42+ const licenseTracker = createLicenseStatusTracker (
43+ cliTracker ,
44+ localStackAuthenticationTracker ,
45+ outputChannel ,
46+ ) ;
4347 const end = Date . now ( ) ;
4448 outputChannel . trace (
4549 `[setup-status]: Initialized dependencies in ${ ms ( end - start , { long : true } ) } ` ,
@@ -53,7 +57,9 @@ export async function createSetupStatusTracker(
5357 licenseTracker : licenseTracker . status ( ) ,
5458 } ;
5559
56- const notInitialized = Object . values ( statuses ) . some ( ( check ) => check === undefined ) ;
60+ const notInitialized = Object . values ( statuses ) . some (
61+ ( check ) => check === undefined ,
62+ ) ;
5763 if ( notInitialized ) {
5864 outputChannel . trace (
5965 `[setup-status] File watchers not initialized yet, skipping status check : ${ JSON . stringify (
@@ -69,7 +75,9 @@ export async function createSetupStatusTracker(
6975 return ;
7076 }
7177
72- const setupRequired = Object . values ( statuses ) . some ( ( status ) => status === "setup_required" ) ;
78+ const setupRequired = Object . values ( statuses ) . some (
79+ ( status ) => status === "setup_required" ,
80+ ) ;
7381 const newStatus = setupRequired ? "setup_required" : "ok" ;
7482 if ( status !== newStatus ) {
7583 status = newStatus ;
@@ -139,7 +147,7 @@ export async function createSetupStatusTracker(
139147
140148interface StatusTracker {
141149 status ( ) : SetupStatus | undefined ;
142- onChange ( callback : ( status : SetupStatus | undefined ) => void ) : void ;
150+ onChange ( callback : ( status : SetupStatus | undefined ) => void ) : void ;
143151 dispose ( ) : Promise < void > ;
144152 check ( ) : void ;
145153}
@@ -159,11 +167,11 @@ function createFileStatusTracker(
159167 outputChannel : LogOutputChannel ,
160168 outputChannelPrefix : string ,
161169 files : string [ ] ,
162- check : ( ) => Promise < SetupStatus | undefined > | SetupStatus | undefined ,
170+ check : ( ) => Promise < SetupStatus | undefined > | SetupStatus | undefined ,
163171) : StatusTracker {
164172 let status : SetupStatus | undefined ;
165173
166- const emitter = createEmitter < SetupStatus | undefined > ( outputChannel ) ;
174+ const emitter = createEmitter < SetupStatus | undefined > ( outputChannel ) ;
167175
168176 const updateStatus = immediateOnce ( async ( ) => {
169177 const newStatus = await Promise . resolve ( check ( ) ) ;
@@ -210,7 +218,7 @@ function createFileStatusTracker(
210218 async dispose ( ) {
211219 await watcher . close ( ) ;
212220 } ,
213- check ( ) {
221+ check ( ) {
214222 return updateStatus ( ) ;
215223 } ,
216224 } ;
@@ -268,26 +276,29 @@ function createLicenseStatusTracker(
268276 authTracker : StatusTracker ,
269277 outputChannel : LogOutputChannel ,
270278) : StatusTracker {
271- const tracker = createFileStatusTracker (
279+ const licenseTracker = createFileStatusTracker (
272280 outputChannel ,
273281 "[setup-status.license]" ,
274282 [ LICENSE_FILENAME ] ,
275- async ( ) =>
276- {
277- const cliPath = cliTracker . cliPath ( ) ;
278- if ( ! cliPath ) {
279- return undefined
280- }
283+ async ( ) => {
284+ const cliPath = cliTracker . cliPath ( ) ;
285+ if ( ! cliPath ) {
286+ return undefined ;
287+ }
288+
289+ const isLicenseValid = await checkIsLicenseValid ( cliPath , outputChannel ) ;
281290
282- const isLicenseValid = await checkIsLicenseValid ( cliPath , outputChannel ) ;
283-
284- return isLicenseValid ? "ok" : "setup_required"
285- } ,
291+ return isLicenseValid ? "ok" : "setup_required" ;
292+ } ,
286293 ) ;
287294
295+ authTracker . onChange ( ( ) => {
296+ licenseTracker . check ( ) ;
297+ } ) ;
298+
288299 cliTracker . onCliPathChange ( ( ) => {
289- tracker . check ( ) ;
290- } )
300+ licenseTracker . check ( ) ;
301+ } ) ;
291302
292- return tracker ;
303+ return licenseTracker ;
293304}
0 commit comments