Skip to content

Commit 686302a

Browse files
committed
feat: change welcome view depending on version check status
1 parent 0394c90 commit 686302a

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

package.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,18 @@
123123
"viewsWelcome": [
124124
{
125125
"view": "vscode-task.tasks",
126-
"contents": "No Taskfile found in this workspace. Click the button below to get started and initialize a new Taskfile.\n[Initialize Taskfile](command:vscode-task.init)\nTo learn more about how to use Task [read our docs](https://taskfile.dev)."
126+
"contents": "Task not installed. Click the button below to install it.\n[Install Task](command:vscode-task.openInstallation)\nTo learn more about how to use Task [read our docs](https://taskfile.dev).",
127+
"when": "vscode-task:status == 'notInstalled'"
128+
},
129+
{
130+
"view": "vscode-task.tasks",
131+
"contents": "Task is out of date. Click the button below to update it.\n[Update Task](command:vscode-task.openInstallation)\nTo learn more about how to use Task [read our docs](https://taskfile.dev).",
132+
"when": "vscode-task:status == 'outOfDate'"
133+
},
134+
{
135+
"view": "vscode-task.tasks",
136+
"contents": "No Taskfile found in this workspace. Click the button below to get started and initialize a new Taskfile.\n[Initialize Taskfile](command:vscode-task.init)\nTo learn more about how to use Task [read our docs](https://taskfile.dev).",
137+
"when": "vscode-task:status == 'noTaskfile'"
127138
}
128139
],
129140
"menus": {

src/services/taskfile.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ class TaskfileService {
3636
return `${settings.path} ${command}`;
3737
}
3838

39-
public async checkInstallation(): Promise<void> {
39+
public async checkInstallation(): Promise<string> {
4040
return await new Promise((resolve) => {
4141
let command = this.command('--version');
4242
cp.exec(command, (_, stdout: string, stderr: string) => {
4343

4444
// If the version is a devel version, ignore all version checks
4545
if (stdout.includes("devel")) {
46-
return resolve();
46+
return resolve("ready");
4747
}
4848

4949
// Get the installed version of task (if any)
@@ -52,19 +52,19 @@ class TaskfileService {
5252
// If there is an error fetching the version, assume task is not installed
5353
if (stderr !== "" || version === undefined) {
5454
vscode.window.showErrorMessage("Task command not found.", "Install").then(this.buttonCallback);
55-
return resolve();
55+
return resolve("notInstalled");
5656
}
5757

5858
// If the current version is older than the minimum required version, show an error
5959
if (version && version.compare(minimumRequiredVersion) < 0) {
6060
vscode.window.showErrorMessage(`Task v${minimumRequiredVersion} is required to run this extension. Your current version is v${version}.`, "Update").then(this.buttonCallback);
61-
return resolve();
61+
return resolve("outOfDate");
6262
}
6363

6464
// If the current version is older than the minimum recommended version, show a warning
6565
if (version && version.compare(minimumRecommendedVersion) < 0) {
6666
vscode.window.showWarningMessage(`Task v${minimumRecommendedVersion} is recommended to run this extension. Your current version is v${version} which doesn't support some features.`, "Update").then(this.buttonCallback);
67-
return resolve();
67+
return resolve("ready");
6868
}
6969

7070
// If a newer version is available, show a message

src/task.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export class TaskExtension {
1212
constructor() {
1313
this._activityBar = new elements.ActivityBar();
1414
this._watcher = vscode.workspace.createFileSystemWatcher("**/*.{yml,yaml}");
15-
services.taskfile.checkInstallation();
15+
services.taskfile.checkInstallation().then(status => {
16+
vscode.commands.executeCommand('setContext', 'vscode-task:status', status);
17+
});
1618
this.setTreeNesting(settings.treeNesting);
1719
}
1820

0 commit comments

Comments
 (0)