Skip to content

Commit f59e00f

Browse files
committed
wip
1 parent 51a86bc commit f59e00f

File tree

4 files changed

+51
-9
lines changed

4 files changed

+51
-9
lines changed

src/plugins/setup.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import { updateDockerImage } from "../utils/setup.ts";
2020
import { get_setup_ended } from "../utils/telemetry.ts";
2121

2222
async function getValidCliPath() {
23-
const cli = await findLocalStack()
23+
const cli = await findLocalStack();
2424
if (!cli.cliPath || !cli.executable || !cli.found || !cli.upToDate) {
25-
return
25+
return;
2626
}
27-
return cli.cliPath
27+
return cli.cliPath;
2828
}
2929

3030
export default createPlugin(
@@ -53,8 +53,6 @@ export default createPlugin(
5353
},
5454
});
5555

56-
const cliPath = cliStatusTracker.cliPath();
57-
5856
void window.withProgress(
5957
{
6058
location: ProgressLocation.Notification,
@@ -238,7 +236,8 @@ export default createPlugin(
238236
// we must find it manually. This may occur when installing the
239237
// CLI as part of the setup process: the CLI status tracker will
240238
// detect the CLI path the next tick.
241-
const cliPath = cliStatusTracker.cliPath() ?? await getValidCliPath();
239+
const cliPath =
240+
cliStatusTracker.cliPath() ?? (await getValidCliPath());
242241
if (!cliPath) {
243242
void window.showErrorMessage(
244243
"Could not access the LocalStack CLI.",

src/plugins/status-bar.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@ import type { QuickPickItem } from "vscode";
33

44
import { createPlugin } from "../plugins.ts";
55
import { immediateOnce } from "../utils/immediate-once.ts";
6+
import type { LocalStackStatus } from "../utils/localstack-status.ts";
7+
import type { SetupStatus } from "../utils/setup-status.ts";
8+
9+
function getStatusText(options: {
10+
cliStatus: SetupStatus;
11+
localStackStatus: LocalStackStatus;
12+
cliOutdated: boolean | undefined;
13+
}) {
14+
if (options.cliStatus === "ok") {
15+
return options.localStackStatus;
16+
}
17+
18+
if (options.cliOutdated) {
19+
return "CLI outdated";
20+
}
21+
22+
return "CLI not installed";
23+
}
624

725
export default createPlugin(
826
"status-bar",
@@ -83,6 +101,7 @@ export default createPlugin(
83101
const setupStatus = setupStatusTracker.status();
84102
const localStackStatus = localStackStatusTracker.status();
85103
const cliStatus = cliStatusTracker.status();
104+
const cliOutdated = cliStatusTracker.outdated();
86105
outputChannel.trace(
87106
`[status-bar] setupStatus=${setupStatus} localStackStatus=${localStackStatus} cliStatus=${cliStatus}`,
88107
);
@@ -111,8 +130,11 @@ export default createPlugin(
111130
? "$(sync~spin)"
112131
: "$(localstack-logo)";
113132

114-
const statusText =
115-
cliStatus === "ok" ? `${localStackStatus}` : "not installed";
133+
const statusText = getStatusText({
134+
cliOutdated,
135+
cliStatus,
136+
localStackStatus,
137+
});
116138
statusBarItem.text = `${icon} LocalStack: ${statusText}`;
117139

118140
statusBarItem.tooltip = "Show LocalStack commands";

src/utils/cli.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,16 @@ export interface CliStatusTracker extends Disposable {
166166
onStatusChange(callback: (status: SetupStatus | undefined) => void): void;
167167
cliPath(): string | undefined;
168168
onCliPathChange(callback: (cliPath: string | undefined) => void): void;
169+
outdated(): boolean | undefined;
170+
onOutdatedChange(callback: (outdated: boolean | undefined) => void): void;
169171
}
170172

171173
export function createCliStatusTracker(
172174
outputChannel: LogOutputChannel,
173175
): CliStatusTracker {
174176
const status = createValueEmitter<SetupStatus>();
175177
const cliPath = createValueEmitter<string | undefined>();
178+
const outdated = createValueEmitter<boolean | undefined>();
176179

177180
const track = immediateOnce(async () => {
178181
const newCli = await findLocalStack().catch(() => undefined);
@@ -183,7 +186,11 @@ export function createCliStatusTracker(
183186
? "ok"
184187
: "setup_required",
185188
);
186-
cliPath.setValue(newCli?.cliPath);
189+
// cliPath.setValue(newCli?.cliPath);
190+
cliPath.setValue(newCli?.upToDate ? newCli?.cliPath : undefined);
191+
outdated.setValue(
192+
newCli?.upToDate !== undefined ? !newCli.upToDate : undefined,
193+
);
187194
});
188195

189196
const watcher = watch(
@@ -224,6 +231,12 @@ export function createCliStatusTracker(
224231
onStatusChange(callback) {
225232
status.onChange(callback);
226233
},
234+
outdated() {
235+
return outdated.value();
236+
},
237+
onOutdatedChange(callback) {
238+
outdated.onChange(callback);
239+
},
227240
async dispose() {
228241
await watcher.close();
229242
},

src/utils/setup-status.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ function createLicenseStatusTracker(
278278
"[setup-status.license]",
279279
[LICENSE_FILENAME],
280280
async () => {
281+
if (cliTracker.outdated()) {
282+
return "setup_required";
283+
}
284+
281285
const cliPath = cliTracker.cliPath();
282286
if (!cliPath) {
283287
return undefined;
@@ -297,5 +301,9 @@ function createLicenseStatusTracker(
297301
licenseTracker.check();
298302
});
299303

304+
cliTracker.onOutdatedChange(() => {
305+
licenseTracker.check();
306+
});
307+
300308
return licenseTracker;
301309
}

0 commit comments

Comments
 (0)