A simpler way to view django projects
still need to figure if django project
4 files changed, +44 -8
+10-2package.json
| @@ -12,6 +12,14 @@ | ||
| 12 | 12 | "activationEvents": [], |
| 13 | 13 | "main": "./out/extension.js", |
| 14 | 14 | "contributes": { |
| 15 | + "commands": [ | |
| 16 | + { | |
| 17 | + "command": "django-overview.managePyExists", | |
| 18 | + "title": "Check if manage.py exists", | |
| 19 | + "category": "Django Overview", | |
| 20 | + "icon": "resources/django.svg" | |
| 21 | + } | |
| 22 | + ], | |
| 15 | 23 | "viewsContainers": { |
| 16 | 24 | "activitybar": [ |
| 17 | 25 | { |
| @@ -28,8 +36,8 @@ | ||
| 28 | 36 | "name": "Current Project" |
| 29 | 37 | }, |
| 30 | 38 | { |
| 31 | - "id": "django-overview.commands", | |
| 32 | - "name": "Commands" | |
| 39 | + "id": "django-overview.manage", | |
| 40 | + "name": "Manage" | |
| 33 | 41 | } |
| 34 | 42 | ] |
| 35 | 43 | } |
+21-0src/commands.ts
| @@ -0,0 +1,21 @@ | ||
| 1 | +import * as vscode from "vscode"; | |
| 2 | + | |
| 3 | +const managePyExists = () => { | |
| 4 | + vscode.workspace | |
| 5 | + .findFiles("**/manage.py", "**/node_modules/**", 1) | |
| 6 | + .then((files) => { | |
| 7 | + let managePyExists = files.length > 0; | |
| 8 | + vscode.commands.executeCommand( | |
| 9 | + "setContext", | |
| 10 | + "managePyExists", | |
| 11 | + managePyExists | |
| 12 | + ); | |
| 13 | + }); | |
| 14 | +}; | |
| 15 | + | |
| 16 | +export default [ | |
| 17 | + vscode.commands.registerCommand( | |
| 18 | + "django-overview.managePyExists", | |
| 19 | + managePyExists | |
| 20 | + ), | |
| 21 | +]; |
+4-6src/extension.ts
| @@ -1,13 +1,11 @@ | ||
| 1 | 1 | import * as vscode from "vscode"; |
| 2 | 2 | import ProjectDataProvider from "./providers/project"; |
| 3 | +import providers from "./providers"; | |
| 4 | +import commands from "./commands"; | |
| 3 | 5 | |
| 4 | 6 | export function activate(context: vscode.ExtensionContext) { |
| 5 | - context.subscriptions.concat([ | |
| 6 | - vscode.window.registerTreeDataProvider( | |
| 7 | - "django-overview.project", | |
| 8 | - new ProjectDataProvider() | |
| 9 | - ), | |
| 10 | - ]); | |
| 7 | + context.subscriptions.concat(providers); | |
| 8 | + context.subscriptions.concat(commands); | |
| 11 | 9 | } |
| 12 | 10 | |
| 13 | 11 | // This method is called when your extension is deactivated |
+9-0src/providers/index.ts
| @@ -0,0 +1,9 @@ | ||
| 1 | +import * as vscode from "vscode"; | |
| 2 | +import ProjectDataProvider from "./project"; | |
| 3 | + | |
| 4 | +export default [ | |
| 5 | + vscode.window.registerTreeDataProvider( | |
| 6 | + "django-overview.project", | |
| 7 | + new ProjectDataProvider() | |
| 8 | + ), | |
| 9 | +]; |