Skip to content

Commit af4c6d6

Browse files
committed
Add repeating license check to setup flow
1 parent b5fe840 commit af4c6d6

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/plugins/setup.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import os from "node:os";
2-
31
import { commands, ProgressLocation, window } from "vscode";
2+
import type { LogOutputChannel } from "vscode";
43

54
import { createPlugin } from "../plugins.ts";
65
import {
@@ -167,17 +166,23 @@ export default createPlugin(
167166

168167
/////////////////////////////////////////////////////////////////////
169168
progress.report({ message: "Checking LocalStack license..." });
169+
170+
//TODO try to activate the license first
171+
170172
const licenseIsValid = await minDelay(
171173
checkIsLicenseValid(outputChannel),
172174
);
173175
if (licenseIsValid) {
174-
progress.report({ message: "License verified succesfully..." });
176+
progress.report({
177+
message: "License verified successfully...",
178+
});
175179
} else {
176180
progress.report({
177181
message:
178182
"License is not valid or not assigned, please check License settings page...",
179183
});
180184
commands.executeCommand("localstack.openLicensePage");
185+
await checkLicenseUntilValid(outputChannel);
181186
}
182187

183188
/////////////////////////////////////////////////////////////////////
@@ -238,3 +243,18 @@ export default createPlugin(
238243
}
239244
},
240245
);
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

Comments
 (0)