66 lines
2.2 KiB
TypeScript
66 lines
2.2 KiB
TypeScript
import * as path from "path";
|
|
import * as vscode from "vscode";
|
|
import { resolveTaskLocations } from "@/commands/resolveTaskLocations";
|
|
import { TASK_FILE_EXTENSION } from "@/model/taskFile";
|
|
import { FsTaskRepository } from "@/storage/FsTaskRepository";
|
|
import { NodeFileSystem } from "@/storage/NodeFileSystem";
|
|
import { VscodeConfigProvider } from "@/storage/VscodeConfigProvider";
|
|
import { registerTaskCommands } from "@/ui/taskCommands";
|
|
import { registerTaskDecorations } from "@/ui/taskDecorations";
|
|
import { registerTaskDiagnostics } from "@/ui/taskDiagnostics";
|
|
import { TaskDashboardPanel } from "@/views/taskDashboardPanel";
|
|
import { TaskKanbanPanel } from "@/views/taskKanbanPanel";
|
|
import { TaskTreeProvider } from "@/views/taskTreeProvider";
|
|
|
|
export function activate(context: vscode.ExtensionContext) {
|
|
const fileSystem = new NodeFileSystem();
|
|
const config = new VscodeConfigProvider();
|
|
const repo = new FsTaskRepository(fileSystem, TASK_FILE_EXTENSION);
|
|
const tree = new TaskTreeProvider(repo, config);
|
|
|
|
const onTasksMutated = (): void => {
|
|
tree.refresh();
|
|
TaskDashboardPanel.refreshIfOpen();
|
|
TaskKanbanPanel.refreshIfOpen();
|
|
};
|
|
|
|
context.subscriptions.push(
|
|
vscode.window.registerTreeDataProvider("xboctukFlow.tasks", tree),
|
|
);
|
|
|
|
for (const location of resolveTaskLocations(config)) {
|
|
const taskPattern = path
|
|
.join(location.folderPath, `*${TASK_FILE_EXTENSION}`)
|
|
.replace(/\\/g, "/");
|
|
const watcher = vscode.workspace.createFileSystemWatcher(taskPattern);
|
|
watcher.onDidCreate(onTasksMutated);
|
|
watcher.onDidChange(onTasksMutated);
|
|
watcher.onDidDelete(onTasksMutated);
|
|
context.subscriptions.push(watcher);
|
|
}
|
|
|
|
const statusBarItem = vscode.window.createStatusBarItem(
|
|
vscode.StatusBarAlignment.Left,
|
|
);
|
|
statusBarItem.text = "$(checklist) Tasks";
|
|
statusBarItem.command = "xboctukFlow.openDashboard";
|
|
statusBarItem.tooltip = "XBOCTuK Flow — Open Dashboard";
|
|
statusBarItem.show();
|
|
context.subscriptions.push(statusBarItem);
|
|
|
|
registerTaskDiagnostics(context);
|
|
registerTaskDecorations(context);
|
|
|
|
registerTaskCommands(context, {
|
|
repo,
|
|
config,
|
|
tree,
|
|
onTasksMutated: () => {
|
|
TaskDashboardPanel.refreshIfOpen();
|
|
TaskKanbanPanel.refreshIfOpen();
|
|
},
|
|
});
|
|
}
|
|
|
|
export function deactivate() {}
|