1- import os from "node:os" ;
2-
31import { commands , ProgressLocation , window } from "vscode" ;
42
53import { createPlugin } from "../plugins.ts" ;
@@ -10,6 +8,11 @@ import {
108} from "../utils/authenticate.ts" ;
119import { configureAwsProfiles } from "../utils/configure-aws.ts" ;
1210import { runInstallProcess } from "../utils/install.ts" ;
11+ import {
12+ activateLicense ,
13+ checkIsLicenseValid ,
14+ activateLicenseUntilValid ,
15+ } from "../utils/license.ts" ;
1316import { minDelay } from "../utils/promises.ts" ;
1417
1518export default createPlugin (
@@ -122,8 +125,6 @@ export default createPlugin(
122125 progress . report ( {
123126 message :
124127 "Waiting for authentication response from the browser..." ,
125- // message: "Waiting for browser response...",
126- // message: "Waiting for authentication response...",
127128 } ) ;
128129 const { authToken } = await minDelay (
129130 requestAuthentication ( context , cancellationToken ) ,
@@ -146,7 +147,6 @@ export default createPlugin(
146147
147148 /////////////////////////////////////////////////////////////////////
148149 progress . report ( {
149- // message: "Authenticating...",
150150 message : "Authenticating to file..." ,
151151 } ) ;
152152 await minDelay ( saveAuthToken ( authToken , outputChannel ) ) ;
@@ -168,6 +168,38 @@ export default createPlugin(
168168 }
169169 }
170170
171+ /////////////////////////////////////////////////////////////////////
172+ progress . report ( { message : "Checking LocalStack license..." } ) ;
173+
174+ // If an auth token has just been obtained or LocalStack has never been started,
175+ // then there will be no license info to be reported by `localstack license info`.
176+ // Also, an expired license could be cached.
177+ // Activating the license pre-emptively to know its state during the setup process.
178+ const licenseIsValid = await minDelay (
179+ activateLicense ( outputChannel ) . then ( ( ) =>
180+ checkIsLicenseValid ( outputChannel ) ,
181+ ) ,
182+ ) ;
183+ if ( ! licenseIsValid ) {
184+ progress . report ( {
185+ message :
186+ "License is not valid or not assigned. Open License settings page to activate it." ,
187+ } ) ;
188+
189+ commands . executeCommand ( "localstack.openLicensePage" ) ;
190+
191+ await activateLicenseUntilValid (
192+ outputChannel ,
193+ cancellationToken ,
194+ ) ;
195+ }
196+
197+ if ( cancellationToken . isCancellationRequested ) {
198+ return ;
199+ }
200+
201+ //TODO add telemetry
202+
171203 /////////////////////////////////////////////////////////////////////
172204 progress . report ( {
173205 message : "Configuring AWS profiles..." ,
0 commit comments