11import { commands , ProgressLocation , window } from "vscode" ;
2- import type { LogOutputChannel } from "vscode" ;
32
43import { createPlugin } from "../plugins.ts" ;
54import {
65 checkIsAuthenticated ,
7- checkIsLicenseValid ,
86 requestAuthentication ,
97 saveAuthToken ,
108} from "../utils/authenticate.ts" ;
11- import { execLocalStack } from "../utils/cli.ts" ;
129import { configureAwsProfiles } from "../utils/configure-aws.ts" ;
1310import { runInstallProcess } from "../utils/install.ts" ;
11+ import {
12+ activateLicense ,
13+ checkIsLicenseValid ,
14+ activateLicenseUntilValid ,
15+ } from "../utils/license.ts" ;
1416import { minDelay } from "../utils/promises.ts" ;
1517
1618export default createPlugin (
@@ -172,9 +174,7 @@ export default createPlugin(
172174 // then there will be no license info to be reported by `localstack license info`.
173175 // Also, an expired license could be cached.
174176 // Activating the license pre-emptively to know its state during the setup process.
175- await execLocalStack ( [ "license" , "activate" ] , {
176- outputChannel,
177- } ) ;
177+ await activateLicense ( outputChannel ) ;
178178 const licenseIsValid = await minDelay (
179179 checkIsLicenseValid ( outputChannel ) ,
180180 ) ;
@@ -190,7 +190,7 @@ export default createPlugin(
190190
191191 commands . executeCommand ( "localstack.openLicensePage" ) ;
192192
193- await checkLicenseUntilValid ( outputChannel ) ;
193+ await activateLicenseUntilValid ( outputChannel ) ;
194194 }
195195 //TODO add telemetry
196196
@@ -252,19 +252,3 @@ export default createPlugin(
252252 }
253253 } ,
254254) ;
255-
256- async function checkLicenseUntilValid (
257- outputChannel : LogOutputChannel ,
258- ) : Promise < void > {
259- while ( true ) {
260- const licenseIsValid = await checkIsLicenseValid ( outputChannel ) ;
261- if ( licenseIsValid ) {
262- break ;
263- }
264- await execLocalStack ( [ "license" , "activate" ] , {
265- outputChannel,
266- } ) ;
267- // Wait before trying again
268- await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) ) ;
269- }
270- }
0 commit comments