|
1 | | -import os from "node:os"; |
2 | | - |
3 | 1 | import { commands, ProgressLocation, window } from "vscode"; |
| 2 | +import type { LogOutputChannel } from "vscode"; |
4 | 3 |
|
5 | 4 | import { createPlugin } from "../plugins.ts"; |
6 | 5 | import { |
@@ -167,17 +166,23 @@ export default createPlugin( |
167 | 166 |
|
168 | 167 | ///////////////////////////////////////////////////////////////////// |
169 | 168 | progress.report({ message: "Checking LocalStack license..." }); |
| 169 | + |
| 170 | + //TODO try to activate the license first |
| 171 | + |
170 | 172 | const licenseIsValid = await minDelay( |
171 | 173 | checkIsLicenseValid(outputChannel), |
172 | 174 | ); |
173 | 175 | if (licenseIsValid) { |
174 | | - progress.report({ message: "License verified succesfully..." }); |
| 176 | + progress.report({ |
| 177 | + message: "License verified successfully...", |
| 178 | + }); |
175 | 179 | } else { |
176 | 180 | progress.report({ |
177 | 181 | message: |
178 | 182 | "License is not valid or not assigned, please check License settings page...", |
179 | 183 | }); |
180 | 184 | commands.executeCommand("localstack.openLicensePage"); |
| 185 | + await checkLicenseUntilValid(outputChannel); |
181 | 186 | } |
182 | 187 |
|
183 | 188 | ///////////////////////////////////////////////////////////////////// |
@@ -238,3 +243,18 @@ export default createPlugin( |
238 | 243 | } |
239 | 244 | }, |
240 | 245 | ); |
| 246 | + |
| 247 | +async function checkLicenseUntilValid( |
| 248 | + outputChannel: LogOutputChannel, |
| 249 | +): Promise<void> { |
| 250 | + while (true) { |
| 251 | + const licenseIsValid = await checkIsLicenseValid(outputChannel); |
| 252 | + if (licenseIsValid) { |
| 253 | + break; |
| 254 | + } |
| 255 | + //TODO try to activate the license |
| 256 | + |
| 257 | + // Wait 2 seconds before trying again |
| 258 | + await new Promise((resolve) => setTimeout(resolve, 2000)); |
| 259 | + } |
| 260 | +} |
0 commit comments