80 lines
2.4 KiB
TypeScript
80 lines
2.4 KiB
TypeScript
import * as path from "path";
|
|
import * as vscode from "vscode";
|
|
import { FsTaskRepository } from "@/storage/FsTaskRepository";
|
|
import { NodeFileSystem } from "@/storage/NodeFileSystem";
|
|
import { VscodeConfigProvider } from "@/storage/VscodeConfigProvider";
|
|
import { TaskTreeProvider } from "@/views/taskTreeProvider";
|
|
|
|
export function activate(context: vscode.ExtensionContext) {
|
|
const fileSystem = new NodeFileSystem();
|
|
const configStore = new VscodeConfigProvider();
|
|
const taskStore = new FsTaskRepository(
|
|
fileSystem,
|
|
configStore.getFileExtension(),
|
|
);
|
|
const taskTreeProvider = new TaskTreeProvider(taskStore, configStore);
|
|
|
|
vscode.window.registerTreeDataProvider(
|
|
"projectTasks.tasks",
|
|
taskTreeProvider,
|
|
);
|
|
|
|
const projectPath = configStore.getProjectTaskPath();
|
|
if (projectPath) {
|
|
const ext = configStore.getFileExtension();
|
|
const taskPattern = path.join(projectPath, `*${ext}`).replace(/\\/g, "/");
|
|
const watcher = vscode.workspace.createFileSystemWatcher(taskPattern);
|
|
watcher.onDidCreate(() => taskTreeProvider.refresh());
|
|
watcher.onDidChange(() => taskTreeProvider.refresh());
|
|
watcher.onDidDelete(() => taskTreeProvider.refresh());
|
|
context.subscriptions.push(watcher);
|
|
}
|
|
|
|
const statusBarItem = vscode.window.createStatusBarItem(
|
|
vscode.StatusBarAlignment.Left,
|
|
);
|
|
statusBarItem.text = "$(checklist) Tasks";
|
|
statusBarItem.command = "projectTasks.openDashboard";
|
|
statusBarItem.tooltip = "Project Tasks — Open Dashboard";
|
|
statusBarItem.show();
|
|
context.subscriptions.push(statusBarItem);
|
|
|
|
const createTaskCommand = vscode.commands.registerCommand(
|
|
"projectTasks.createTask",
|
|
async () => {
|
|
const title = await vscode.window.showInputBox({
|
|
prompt: "Task title",
|
|
placeHolder: "Enter task title...",
|
|
});
|
|
if (!title) return;
|
|
|
|
const projectPath = configStore.getProjectTaskPath();
|
|
if (!projectPath) {
|
|
vscode.window.showErrorMessage("Open a workspace folder first");
|
|
return;
|
|
}
|
|
|
|
await taskStore.create(projectPath, {
|
|
title,
|
|
description: "",
|
|
status: "todo",
|
|
priority: "medium",
|
|
tags: [],
|
|
assignee: "",
|
|
});
|
|
vscode.window.showInformationMessage(`Task created: ${title}`);
|
|
},
|
|
);
|
|
|
|
const openDashboardCommand = vscode.commands.registerCommand(
|
|
"projectTasks.openDashboard",
|
|
() => {
|
|
vscode.window.showInformationMessage("Dashboard coming soon!");
|
|
},
|
|
);
|
|
|
|
context.subscriptions.push(createTaskCommand, openDashboardCommand);
|
|
}
|
|
|
|
export function deactivate() {}
|