diff --git a/.github/workflows/new-pull-request-comment.yml b/.github/workflows/new-pull-request-comment.yml
index 4527c8f56f3..a2509f9acac 100644
--- a/.github/workflows/new-pull-request-comment.yml
+++ b/.github/workflows/new-pull-request-comment.yml
@@ -29,7 +29,7 @@ jobs:
| JSON, structs, primitives and collections | `@hasanaburayyan`
| Platforms and plugins | `@hasanaburayyan`
| Frontend resources (website, react, etc) | `@tsuf239`
- | Language design | `@eladb`
+ | Language design | `@chriscbr`
| VSCode extension and language server | `@markmcculloh`
| Compiler architecture, inflights, lifting | `@yoav-steinberg`
| Wing Testing Framework | `@tsuf239`
diff --git a/apps/vscode-wing/.projen/deps.json b/apps/vscode-wing/.projen/deps.json
index 87de4c79094..24b6d81e897 100644
--- a/apps/vscode-wing/.projen/deps.json
+++ b/apps/vscode-wing/.projen/deps.json
@@ -40,16 +40,6 @@
"name": "@vscode/vsce",
"type": "build"
},
- {
- "name": "@wingconsole/app",
- "version": "workspace:^",
- "type": "build"
- },
- {
- "name": "@wingconsole/server",
- "version": "workspace:^",
- "type": "build"
- },
{
"name": "eslint-config-prettier",
"type": "build"
diff --git a/apps/vscode-wing/.projenrc.ts b/apps/vscode-wing/.projenrc.ts
index 2907435a702..bfa1bc0a95f 100644
--- a/apps/vscode-wing/.projenrc.ts
+++ b/apps/vscode-wing/.projenrc.ts
@@ -67,8 +67,6 @@ const project = new TypeScriptAppProject({
"@vscode/vsce",
"@types/node-fetch",
"@types/ws",
- "@wingconsole/app@workspace:^",
- "@wingconsole/server@workspace:^",
"winglang@workspace:^",
],
});
@@ -135,61 +133,14 @@ const contributes: VSCodeExtensionContributions = {
dark: "resources/icon-dark.svg",
},
},
- {
- command: "wing.openFile",
- title: "Open source file",
- icon: {
- light: "resources/icon-light.svg",
- dark: "resources/icon-dark.svg",
- },
- },
- {
- command: "wingConsole.openResource",
- title: "Open resource",
- },
- {
- command: "wingConsole.runTest",
- title: "Run test",
- icon: {
- light: "resources/play-light.svg",
- dark: "resources/play-dark.svg",
- },
- },
- {
- command: "wingConsole.runAllTests",
- title: "Run all tests",
- icon: {
- light: "resources/play-all-light.svg",
- dark: "resources/play-all-dark.svg",
- },
- },
],
menus: {
"editor/title": [
{
- when: "resourceLangId == wing && activeWebviewPanelId != 'wing.console'",
+ when: "resourceLangId == wing",
command: "wing.openConsole",
group: "navigation",
},
- {
- when: "resourceLangId != wing && activeWebviewPanelId == 'wing.console'",
- command: "wing.openFile",
- group: "navigation",
- },
- ],
- "view/item/context": [
- {
- command: "wingConsole.runTest",
- when: "view == consoleTestsExplorer",
- group: "inline",
- },
- ],
- "explorer/context": [
- {
- command: "wingConsole.runAllTests",
- when: "view == consoleTestsExplorer",
- group: "inline",
- },
],
},
configuration: [
@@ -204,22 +155,6 @@ const contributes: VSCodeExtensionContributions = {
},
},
],
- views: {
- explorer: [
- {
- id: "consoleExplorer",
- name: "Wing Resources",
- },
- {
- id: "consoleTestsExplorer",
- name: "Wing Tests",
- },
- {
- id: "consoleEndpointsExplorer",
- name: "Wing Endpoints",
- },
- ],
- },
};
project.addFields({
diff --git a/apps/vscode-wing/package.json b/apps/vscode-wing/package.json
index db78d4e1169..6b051d72b71 100644
--- a/apps/vscode-wing/package.json
+++ b/apps/vscode-wing/package.json
@@ -36,8 +36,6 @@
"@typescript-eslint/eslint-plugin": "^5",
"@typescript-eslint/parser": "^5",
"@vscode/vsce": "^2.21.0",
- "@wingconsole/app": "workspace:^",
- "@wingconsole/server": "workspace:^",
"eslint": "^8",
"eslint-config-prettier": "^8.10.0",
"eslint-import-resolver-node": "^0.3.9",
@@ -137,61 +135,14 @@
"light": "resources/icon-light.svg",
"dark": "resources/icon-dark.svg"
}
- },
- {
- "command": "wing.openFile",
- "title": "Open source file",
- "icon": {
- "light": "resources/icon-light.svg",
- "dark": "resources/icon-dark.svg"
- }
- },
- {
- "command": "wingConsole.openResource",
- "title": "Open resource"
- },
- {
- "command": "wingConsole.runTest",
- "title": "Run test",
- "icon": {
- "light": "resources/play-light.svg",
- "dark": "resources/play-dark.svg"
- }
- },
- {
- "command": "wingConsole.runAllTests",
- "title": "Run all tests",
- "icon": {
- "light": "resources/play-all-light.svg",
- "dark": "resources/play-all-dark.svg"
- }
}
],
"menus": {
"editor/title": [
{
- "when": "resourceLangId == wing && activeWebviewPanelId != 'wing.console'",
+ "when": "resourceLangId == wing",
"command": "wing.openConsole",
"group": "navigation"
- },
- {
- "when": "resourceLangId != wing && activeWebviewPanelId == 'wing.console'",
- "command": "wing.openFile",
- "group": "navigation"
- }
- ],
- "view/item/context": [
- {
- "command": "wingConsole.runTest",
- "when": "view == consoleTestsExplorer",
- "group": "inline"
- }
- ],
- "explorer/context": [
- {
- "command": "wingConsole.runAllTests",
- "when": "view == consoleTestsExplorer",
- "group": "inline"
}
]
},
@@ -205,23 +156,7 @@
}
}
}
- ],
- "views": {
- "explorer": [
- {
- "id": "consoleExplorer",
- "name": "Wing Resources"
- },
- {
- "id": "consoleTestsExplorer",
- "name": "Wing Tests"
- },
- {
- "id": "consoleEndpointsExplorer",
- "name": "Wing Endpoints"
- }
- ]
- }
+ ]
},
"volta": {
"extends": "../../package.json"
diff --git a/apps/vscode-wing/resources/icon-dark.svg b/apps/vscode-wing/resources/icon-dark.svg
deleted file mode 100644
index a9aec13f73f..00000000000
--- a/apps/vscode-wing/resources/icon-dark.svg
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
diff --git a/apps/vscode-wing/resources/resource-icons/dark/archive-box.svg b/apps/vscode-wing/resources/resource-icons/dark/archive-box.svg
deleted file mode 100644
index f6ef06fab73..00000000000
--- a/apps/vscode-wing/resources/resource-icons/dark/archive-box.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/dark/beaker.svg b/apps/vscode-wing/resources/resource-icons/dark/beaker.svg
deleted file mode 100644
index c45c483c366..00000000000
--- a/apps/vscode-wing/resources/resource-icons/dark/beaker.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/dark/bolt.svg b/apps/vscode-wing/resources/resource-icons/dark/bolt.svg
deleted file mode 100644
index 61574e4aee3..00000000000
--- a/apps/vscode-wing/resources/resource-icons/dark/bolt.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/dark/calculator.svg b/apps/vscode-wing/resources/resource-icons/dark/calculator.svg
deleted file mode 100644
index d79e9726463..00000000000
--- a/apps/vscode-wing/resources/resource-icons/dark/calculator.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/dark/clock.svg b/apps/vscode-wing/resources/resource-icons/dark/clock.svg
deleted file mode 100644
index 87eab2dc2dc..00000000000
--- a/apps/vscode-wing/resources/resource-icons/dark/clock.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/dark/cloud.svg b/apps/vscode-wing/resources/resource-icons/dark/cloud.svg
deleted file mode 100644
index 4eb9e708fbb..00000000000
--- a/apps/vscode-wing/resources/resource-icons/dark/cloud.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/dark/cube.svg b/apps/vscode-wing/resources/resource-icons/dark/cube.svg
deleted file mode 100644
index 8ce57410c00..00000000000
--- a/apps/vscode-wing/resources/resource-icons/dark/cube.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/dark/globe-alt.svg b/apps/vscode-wing/resources/resource-icons/dark/globe-alt.svg
deleted file mode 100644
index ab078d2abb6..00000000000
--- a/apps/vscode-wing/resources/resource-icons/dark/globe-alt.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/dark/megaphone.svg b/apps/vscode-wing/resources/resource-icons/dark/megaphone.svg
deleted file mode 100644
index f5c85040fe1..00000000000
--- a/apps/vscode-wing/resources/resource-icons/dark/megaphone.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/dark/queue-list.svg b/apps/vscode-wing/resources/resource-icons/dark/queue-list.svg
deleted file mode 100644
index 7eec9855d33..00000000000
--- a/apps/vscode-wing/resources/resource-icons/dark/queue-list.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/dark/redis.svg b/apps/vscode-wing/resources/resource-icons/dark/redis.svg
deleted file mode 100644
index 66e31bd3336..00000000000
--- a/apps/vscode-wing/resources/resource-icons/dark/redis.svg
+++ /dev/null
@@ -1,11 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/dark/table-cells.svg b/apps/vscode-wing/resources/resource-icons/dark/table-cells.svg
deleted file mode 100644
index 3902cf36eb9..00000000000
--- a/apps/vscode-wing/resources/resource-icons/dark/table-cells.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/light/archive-box.svg b/apps/vscode-wing/resources/resource-icons/light/archive-box.svg
deleted file mode 100644
index 897ecf080e6..00000000000
--- a/apps/vscode-wing/resources/resource-icons/light/archive-box.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/light/beaker.svg b/apps/vscode-wing/resources/resource-icons/light/beaker.svg
deleted file mode 100644
index 6bd47ac6aa2..00000000000
--- a/apps/vscode-wing/resources/resource-icons/light/beaker.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/light/bolt.svg b/apps/vscode-wing/resources/resource-icons/light/bolt.svg
deleted file mode 100644
index 52b44d7d5b1..00000000000
--- a/apps/vscode-wing/resources/resource-icons/light/bolt.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/light/calculator.svg b/apps/vscode-wing/resources/resource-icons/light/calculator.svg
deleted file mode 100644
index f8c51446893..00000000000
--- a/apps/vscode-wing/resources/resource-icons/light/calculator.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/light/clock.svg b/apps/vscode-wing/resources/resource-icons/light/clock.svg
deleted file mode 100644
index f9ade369484..00000000000
--- a/apps/vscode-wing/resources/resource-icons/light/clock.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/light/cloud.svg b/apps/vscode-wing/resources/resource-icons/light/cloud.svg
deleted file mode 100644
index 6ca053e0754..00000000000
--- a/apps/vscode-wing/resources/resource-icons/light/cloud.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/light/cube.svg b/apps/vscode-wing/resources/resource-icons/light/cube.svg
deleted file mode 100644
index 7bd64203b32..00000000000
--- a/apps/vscode-wing/resources/resource-icons/light/cube.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/light/globe-alt.svg b/apps/vscode-wing/resources/resource-icons/light/globe-alt.svg
deleted file mode 100644
index 4733d467555..00000000000
--- a/apps/vscode-wing/resources/resource-icons/light/globe-alt.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/light/megaphone.svg b/apps/vscode-wing/resources/resource-icons/light/megaphone.svg
deleted file mode 100644
index 8d077b760b5..00000000000
--- a/apps/vscode-wing/resources/resource-icons/light/megaphone.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/light/queue-list.svg b/apps/vscode-wing/resources/resource-icons/light/queue-list.svg
deleted file mode 100644
index fc0f71ee8d4..00000000000
--- a/apps/vscode-wing/resources/resource-icons/light/queue-list.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/light/redis.svg b/apps/vscode-wing/resources/resource-icons/light/redis.svg
deleted file mode 100644
index 930dc657380..00000000000
--- a/apps/vscode-wing/resources/resource-icons/light/redis.svg
+++ /dev/null
@@ -1,11 +0,0 @@
-
diff --git a/apps/vscode-wing/resources/resource-icons/light/table-cells.svg b/apps/vscode-wing/resources/resource-icons/light/table-cells.svg
deleted file mode 100644
index eedec1524f4..00000000000
--- a/apps/vscode-wing/resources/resource-icons/light/table-cells.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/vscode-wing/src/console/console-manager.ts b/apps/vscode-wing/src/console/console-manager.ts
deleted file mode 100644
index e0322d705f0..00000000000
--- a/apps/vscode-wing/src/console/console-manager.ts
+++ /dev/null
@@ -1,349 +0,0 @@
-import {
- window,
- WebviewPanel,
- commands,
- TreeView,
- ViewColumn,
- Uri,
- ExtensionContext,
- Position,
- Range,
-} from "vscode";
-
-import {
- EndpointItem,
- EndpointsExplorerProvider,
-} from "./explorer-providers/EndpointsExplorerProvider";
-import {
- ResourceItem,
- ResourcesExplorerProvider,
-} from "./explorer-providers/ResourcesExplorerProvider";
-import {
- TestItem,
- TestsExplorerProvider,
-} from "./explorer-providers/TestsExplorerProvider";
-import { type Client } from "./services/client";
-import { VIEW_TYPE_CONSOLE } from "../constants";
-import { Loggers } from "../logging";
-
-export interface ConsoleInstance {
- id: string;
- wingfile: string;
- url: string;
- client: Client;
- onDidClose: () => void;
-}
-
-export interface ConsoleManager {
- addInstance: (instance: ConsoleInstance) => Promise;
- getInstance: (instanceId: string) => ConsoleInstance | undefined;
- closeInstance: (instanceId: string) => void;
- setActiveInstance: (instanceId: string) => Promise;
- activeInstances: () => boolean;
- getActiveInstanceId: () => string | undefined;
- stopAll: () => Promise;
-}
-
-export const createConsoleManager = (
- context: ExtensionContext
-): ConsoleManager => {
- const instances: Record = {};
- const resourcesExplorer = new ResourcesExplorerProvider();
- const testsExplorer = new TestsExplorerProvider();
- const endpointsExplorer = new EndpointsExplorerProvider();
-
- let activeInstanceId: string | undefined;
- let webviewPanel: WebviewPanel | undefined;
- let explorerView: TreeView | undefined;
- let testsExplorerView: TreeView | undefined;
- let endpointsExplorerView: TreeView | undefined;
-
- let timeout: NodeJS.Timeout | undefined;
- let logsTimestamp: number = 0;
-
- const registerCommands = () => {
- commands.registerCommand("wingConsole.openResource", async (resourceId) => {
- if (!activeInstanceId) {
- return;
- }
- const activePanel = getInstance(activeInstanceId);
- if (!activePanel) {
- return;
- }
- await activePanel.client.setSelectedNode(resourceId);
- });
-
- commands.registerCommand("wingConsole.runTest", async (test: TestItem) => {
- if (!activeInstanceId) {
- return;
- }
- const activePanel = getInstance(activeInstanceId);
- if (!activePanel) {
- return;
- }
- const tests = testsExplorer.getTests();
- testsExplorer.update(
- tests.map((testItem) => {
- if (testItem.id === test.id) {
- return {
- ...test,
- status: "running",
- };
- }
- return testItem;
- })
- );
- await activePanel.client.runTest(test.id);
- });
-
- commands.registerCommand("wingConsole.runAllTests", async () => {
- if (!activeInstanceId) {
- return;
- }
- const activePanel = getInstance(activeInstanceId);
- if (!activePanel) {
- return;
- }
- const tests = testsExplorer.getTests();
- testsExplorer.update(
- tests.map((testItem) => {
- return {
- ...testItem,
- status: "running",
- };
- })
- );
- await activePanel.client.runAllTests();
- });
- };
-
- const updateLogs = async (instance: ConsoleInstance) => {
- const logs = await instance.client.getLogs({ time: logsTimestamp });
-
- logs.forEach((log) => {
- Loggers.console.appendLine(`[${log.level}] ${log.message}`);
- });
- logsTimestamp = Date.now();
- };
-
- const getTheme = () => {
- const theme = window.activeColorTheme.kind;
- if (theme === 1) {
- return "light";
- }
- return "dark";
- };
-
- const getInstance = (instanceId: string) => {
- if (!instanceId) {
- return;
- }
- return instances[instanceId];
- };
-
- const addInstance = async (instance: ConsoleInstance) => {
- Loggers.console.appendLine(
- `Wing Console is running at http://${instance.url}`
- );
-
- instance.client.onInvalidateQuery({
- onData: async (key) => {
- if (activeInstanceId !== instance.id) {
- return;
- }
- if (timeout) {
- clearTimeout(timeout);
- }
- timeout = setTimeout(async () => {
- if (!key || key === "app.logs") {
- await updateLogs(instance);
- }
- resourcesExplorer.update(await instance.client.listResources());
- testsExplorer.update(await instance.client.listTests());
- endpointsExplorer.update(await instance.client.listEndpoints());
- }, 300);
- },
- onError: (err) => {
- Loggers.console.appendLine(err);
- },
- });
-
- instance.client.onOpenFileInEditor({
- onData: async (data) => {
- const path = data?.path;
- const line = data?.line - 1 || 0;
- const column = data?.column || 0;
-
- const openEditor = window.visibleTextEditors.find((editor) => {
- return editor.document.uri.fsPath === path;
- });
-
- if (!openEditor || !openEditor.viewColumn) {
- await commands.executeCommand(
- "vscode.open",
- Uri.file(path),
- new Position(line, column)
- );
- return;
- }
-
- await commands.executeCommand("workbench.action.focusFirstEditorGroup");
- for (let i = 0; i < openEditor.viewColumn - 1; i++) {
- await commands.executeCommand("workbench.action.focusNextGroup");
- }
- await window.showTextDocument(openEditor.document, {
- selection: new Range(
- new Position(line, column),
- new Position(line, column)
- ),
- });
- },
- onError: (err) => {
- Loggers.console.appendLine(err);
- },
- });
-
- instances[instance.id] = instance;
-
- await setActiveInstance(instance.id);
- };
-
- const setActiveInstance = async (instanceId: string) => {
- const instance = getInstance(instanceId);
- if (!instance) {
- return;
- }
-
- if (!webviewPanel) {
- webviewPanel = window.createWebviewPanel(
- VIEW_TYPE_CONSOLE,
- `Console`,
- ViewColumn.Beside,
- {
- enableScripts: true,
- enableCommandUris: true,
- }
- );
-
- webviewPanel.iconPath = {
- light: Uri.joinPath(
- context.extensionUri,
- "resources",
- "icon-light.svg"
- ),
- dark: Uri.joinPath(context.extensionUri, "resources", "icon-dark.svg"),
- };
-
- webviewPanel.onDidDispose(async () => {
- resourcesExplorer.clear();
- testsExplorer.clear();
- endpointsExplorer.clear();
- webviewPanel = undefined;
- activeInstanceId = undefined;
-
- Object.keys(instances).forEach(async (id) => {
- await closeInstance(id);
- });
- });
- Loggers.console.show();
- }
-
- webviewPanel.title = `${instance.wingfile} - [console]`;
- webviewPanel.webview.html = `
-
-
-
-
-
-
-
-
-
-
- `;
-
- resourcesExplorer.update(await instance.client.listResources());
- testsExplorer.update(await instance.client.listTests());
- endpointsExplorer.update(await instance.client.listEndpoints());
- await updateLogs(instance);
-
- explorerView = window.createTreeView("consoleExplorer", {
- treeDataProvider: resourcesExplorer,
- });
-
- testsExplorerView = window.createTreeView("consoleTestsExplorer", {
- treeDataProvider: testsExplorer,
- });
-
- endpointsExplorerView = window.createTreeView("consoleEndpointsExplorer", {
- treeDataProvider: endpointsExplorer,
- });
-
- context.subscriptions.push(
- webviewPanel,
- explorerView,
- testsExplorerView,
- endpointsExplorerView
- );
- activeInstanceId = instanceId;
- };
-
- const closeInstance = async (instanceId: string) => {
- const instance = getInstance(instanceId);
- if (!instance) {
- return;
- }
- Loggers.console.appendLine(
- `Closing Console instance: '${instance.wingfile}'`
- );
-
- instance.client.close();
- instance.onDidClose();
- resourcesExplorer.clear();
- testsExplorer.clear();
- activeInstanceId = undefined;
- delete instances[instanceId];
-
- if (Object.keys(instances).length === 0) {
- webviewPanel?.dispose();
- webviewPanel = undefined;
- }
- };
-
- registerCommands();
-
- return {
- addInstance,
- getInstance,
- closeInstance,
- setActiveInstance,
- activeInstances: () => {
- return Object.keys(instances).length > 0;
- },
- getActiveInstanceId: () => {
- return activeInstanceId;
- },
- stopAll: async () => {
- Object.keys(instances).forEach(async (id) => {
- await closeInstance(id);
- });
- },
- };
-};
diff --git a/apps/vscode-wing/src/console/explorer-providers/EndpointsExplorerProvider.ts b/apps/vscode-wing/src/console/explorer-providers/EndpointsExplorerProvider.ts
deleted file mode 100644
index 97f02c0b55e..00000000000
--- a/apps/vscode-wing/src/console/explorer-providers/EndpointsExplorerProvider.ts
+++ /dev/null
@@ -1,77 +0,0 @@
-import {
- TreeDataProvider,
- TreeItem,
- TreeItemCollapsibleState,
- Event,
- EventEmitter,
- ThemeIcon,
- Uri,
-} from "vscode";
-
-export class EndpointsExplorerProvider
- implements TreeDataProvider
-{
- private endpoints: EndpointItem[] = [];
-
- private _onDidChangeTreeData: EventEmitter<
- EndpointItem | undefined | null | void
- > = new EventEmitter();
-
- readonly onDidChangeTreeData: Event =
- this._onDidChangeTreeData.event;
-
- constructor(endpoints?: EndpointItem[]) {
- this.endpoints = endpoints || [];
- }
-
- public refresh(): void {
- this._onDidChangeTreeData.fire();
- }
-
- public update(endpoints: EndpointItem[]): void {
- this.endpoints = endpoints;
- this.refresh();
- }
-
- public clear(): void {
- this.update([]);
- }
-
- public getEndpoints(): EndpointItem[] {
- return this.endpoints;
- }
-
- public getTreeItem(element: EndpointItem): TreeItem {
- element.command = {
- command: "vscode.open",
- title: "Open Call",
- arguments: [Uri.parse(element.url)],
- };
- return element;
- }
-
- public getChildren(element?: EndpointItem): Thenable {
- if (!element) {
- return Promise.resolve(
- this.endpoints.map((endpoint) => {
- return new EndpointItem(endpoint.id, endpoint.label, endpoint.url);
- })
- );
- }
- return Promise.resolve([]);
- }
-}
-
-export class EndpointItem extends TreeItem {
- constructor(
- public readonly id: string,
- public readonly label: string,
- public readonly url: string
- ) {
- super(label || "", TreeItemCollapsibleState.None);
- this.tooltip = this.url;
- this.id = id;
- this.url = url;
- this.iconPath = new ThemeIcon("link");
- }
-}
diff --git a/apps/vscode-wing/src/console/explorer-providers/ResourcesExplorerProvider.ts b/apps/vscode-wing/src/console/explorer-providers/ResourcesExplorerProvider.ts
deleted file mode 100644
index bb33ab796c1..00000000000
--- a/apps/vscode-wing/src/console/explorer-providers/ResourcesExplorerProvider.ts
+++ /dev/null
@@ -1,235 +0,0 @@
-import path from "path";
-import type { ExplorerItem } from "@wingconsole/server";
-import {
- TreeItemCollapsibleState,
- TreeItem,
- TreeDataProvider,
- Event,
- EventEmitter,
- ProviderResult,
-} from "vscode";
-
-export class ResourcesExplorerProvider
- implements TreeDataProvider
-{
- private node?: ExplorerItem;
-
- private _onDidChangeTreeData: EventEmitter<
- ResourceItem | undefined | null | void
- > = new EventEmitter();
-
- readonly onDidChangeTreeData: Event =
- this._onDidChangeTreeData.event;
-
- constructor(node?: ExplorerItem) {
- this.node = node;
- }
-
- public refresh(): void {
- this._onDidChangeTreeData.fire();
- }
-
- public update(item?: ExplorerItem): void {
- this.node = item;
- this.refresh();
- }
-
- public clear(): void {
- this.update();
- }
-
- public getTreeItem(element: ResourceItem): TreeItem {
- return {
- ...element,
- command: {
- command: "wingConsole.openResource",
- arguments: [element.id],
- title: "Select Resource",
- },
- };
- }
-
- private getResource(id: string): ExplorerItem | undefined {
- if (!this.node) {
- return undefined;
- }
- const searchChild = (node: ExplorerItem): ExplorerItem | undefined => {
- if (node.id === id) {
- return node;
- }
-
- if (!node.childItems) {
- return;
- }
- for (const child of node.childItems) {
- const resource = searchChild(child);
- if (resource) {
- return resource;
- }
- }
-
- return;
- };
-
- return searchChild(this.node);
- }
-
- private getParentResource(id: string): ExplorerItem | undefined {
- if (!this.node) {
- return;
- }
-
- const searchParent = (node: ExplorerItem): ExplorerItem | undefined => {
- if (!node.childItems) {
- return;
- }
- for (const child of node.childItems) {
- if (child.id === id) {
- return node;
- }
- const resource = searchParent(child);
- if (resource) {
- return resource;
- }
- }
- return;
- };
-
- return searchParent(this.node);
- }
-
- public getParent(element: ResourceItem): ProviderResult {
- if (!this.node || !element.id) {
- return null;
- }
-
- const parentItem = this.getParentResource(element.id);
-
- if (!parentItem) {
- return;
- }
-
- return new ResourceItem(
- parentItem.id,
- parentItem.label,
- parentItem.type,
- TreeItemCollapsibleState.Expanded
- );
- }
-
- public getChildren(element?: ResourceItem): Thenable {
- if (!this.node) {
- return Promise.resolve([]);
- }
- if (!element || !element.id) {
- return Promise.resolve([
- new ResourceItem(
- this.node.id,
- this.node.label,
- this.node.type,
- TreeItemCollapsibleState.Expanded
- ),
- ]);
- }
-
- const childItem = this.getResource(element.id);
-
- if (!childItem?.childItems) {
- return Promise.resolve([]);
- }
-
- return Promise.resolve(
- childItem.childItems.map((child: ExplorerItem) => {
- return new ResourceItem(
- child.id,
- child.label,
- child.type || "",
- child.childItems?.length && child.childItems.length > 0
- ? TreeItemCollapsibleState.Expanded
- : TreeItemCollapsibleState.None
- );
- })
- );
- }
-}
-
-export class ResourceItem extends TreeItem {
- constructor(
- id: string,
- label?: string,
- type?: string,
- state?: TreeItemCollapsibleState
- ) {
- super(label || "", state);
-
- this.id = id;
- this.tooltip = label;
-
- this.iconPath = {
- light: path.join(
- __filename,
- "../../resources/resource-icons/light",
- `${this.getResourceIconName(type, id)}.svg`
- ),
- dark: path.join(
- __filename,
- "../../resources/resource-icons/dark",
- `${this.getResourceIconName(type, id)}.svg`
- ),
- };
- }
-
- private matchTest = (resourceId: string) => {
- const isTest = /(\/test$|\/test:([^/\\])+$)/;
- const isTestHandler = /(\/test$|\/test:.*\/Handler$)/;
-
- return isTest.test(resourceId) || isTestHandler.test(resourceId);
- };
-
- private getResourceIconName = (
- resourceType: string | undefined,
- resourceId?: string
- ) => {
- if (resourceId && this.matchTest(resourceId)) {
- return "beaker";
- }
- switch (resourceType) {
- case "@winglang/sdk.cloud.Bucket": {
- return "archive-box";
- }
- case "@winglang/sdk.cloud.Function": {
- return "bolt";
- }
- case "@winglang/sdk.cloud.Queue": {
- return "queue-list";
- }
- case "@winglang/sdk.cloud.Website": {
- return "globe-alt";
- }
- case "@winglang/sdk.cloud.Counter": {
- return "calculator";
- }
- case "@winglang/sdk.cloud.Topic": {
- return "megaphone";
- }
- case "@winglang/sdk.cloud.Api": {
- return "cloud";
- }
- case "@winglang/sdk.ex.Table": {
- return "table-cells";
- }
- case "@winglang/sdk.cloud.Schedule": {
- return "clock";
- }
- case "@winglang/sdk.ex.Redis": {
- return "redis";
- }
- case "@winglang/sdk.std.Test": {
- return "beaker";
- }
- default: {
- return "cube";
- }
- }
- };
-}
diff --git a/apps/vscode-wing/src/console/explorer-providers/TestsExplorerProvider.ts b/apps/vscode-wing/src/console/explorer-providers/TestsExplorerProvider.ts
deleted file mode 100644
index 7e1a8eeacd0..00000000000
--- a/apps/vscode-wing/src/console/explorer-providers/TestsExplorerProvider.ts
+++ /dev/null
@@ -1,83 +0,0 @@
-import {
- TreeDataProvider,
- TreeItem,
- TreeItemCollapsibleState,
- Event,
- EventEmitter,
- ThemeIcon,
-} from "vscode";
-
-export type TestStatus = "success" | "error" | "running" | "pending";
-
-export class TestsExplorerProvider implements TreeDataProvider {
- private tests: TestItem[] = [];
-
- private _onDidChangeTreeData: EventEmitter<
- TestItem | undefined | null | void
- > = new EventEmitter();
-
- readonly onDidChangeTreeData: Event =
- this._onDidChangeTreeData.event;
-
- constructor(tests?: TestItem[]) {
- this.tests = tests || [];
- }
-
- public refresh(): void {
- this._onDidChangeTreeData.fire();
- }
-
- public update(tests: TestItem[]): void {
- this.tests = tests;
- this.refresh();
- }
-
- public clear(): void {
- this.update([]);
- }
-
- public getTests(): TestItem[] {
- return this.tests;
- }
-
- public getTreeItem(element: TestItem): TreeItem {
- return element;
- }
-
- public getChildren(element?: TestItem): Thenable {
- if (!element) {
- return Promise.resolve(
- this.tests.map((test) => {
- return new TestItem(test.id, test.label, test.time, test.status);
- })
- );
- }
- return Promise.resolve([]);
- }
-}
-
-export class TestItem extends TreeItem {
- constructor(
- public readonly id: string,
- public readonly label?: string,
- public readonly time?: number,
- public readonly status?: TestStatus
- ) {
- super(label || "", TreeItemCollapsibleState.None);
- this.tooltip = this.label;
- this.id = id;
-
- this.description =
- time && status !== "pending" ? `${status} (${time}ms)` : "";
-
- let iconName = "issues";
- if (status === "success") {
- iconName = "check";
- } else if (status === "error") {
- iconName = "error";
- } else if (status === "running") {
- iconName = "sync~spin";
- }
- this.iconPath = new ThemeIcon(iconName);
- }
-}
diff --git a/apps/vscode-wing/src/console/index.ts b/apps/vscode-wing/src/console/index.ts
deleted file mode 100644
index 69d116ff645..00000000000
--- a/apps/vscode-wing/src/console/index.ts
+++ /dev/null
@@ -1,154 +0,0 @@
-import { execSync, spawn } from "child_process";
-import path from "path";
-import fetch from "node-fetch";
-
-const globalAny = global as any;
-globalAny.fetch = fetch;
-globalAny.WebSocket = ws;
-
-import { ExtensionContext, window, workspace } from "vscode";
-import ws from "ws";
-import { type ConsoleManager, createConsoleManager } from "./console-manager";
-import { createClient } from "./services/client";
-import { Loggers } from "../logging";
-
-export class WingConsoleManager {
- consoleManager: ConsoleManager;
-
- wingBin: string | undefined;
-
- constructor(public readonly context: ExtensionContext) {
- this.consoleManager = createConsoleManager(this.context);
-
- window.onDidChangeActiveTextEditor(async (editor) => {
- const instanceId = editor?.document.uri.fsPath;
- if (
- this.consoleManager.activeInstances() &&
- this.consoleManager.getActiveInstanceId() !== instanceId
- ) {
- await this.openConsole();
- }
- });
-
- window.onDidChangeActiveColorTheme(async () => {
- const activeInstanceId = this.consoleManager.getActiveInstanceId();
- if (activeInstanceId) {
- await this.consoleManager.setActiveInstance(activeInstanceId);
- }
- });
-
- workspace.onDidCloseTextDocument(async (textDocument) => {
- if (textDocument.languageId !== "wing") {
- return;
- }
- const instance = this.consoleManager.getInstance(textDocument.uri.fsPath);
- if (instance) {
- this.consoleManager.closeInstance(instance.id);
- }
- });
- }
-
- public setWingBin(wingBin: string) {
- this.wingBin = wingBin;
- }
-
- public async stop() {
- await this.consoleManager.stopAll();
- }
-
- public async openConsole() {
- // get the current active file
- const editor = window.activeTextEditor;
- if (!editor) {
- return;
- }
- const document = editor.document;
- if (document.languageId !== "wing") {
- return;
- }
- const wingfilePath = document.uri.fsPath;
- const wingfile = path.basename(wingfilePath);
-
- if (this.consoleManager.getInstance(wingfilePath)) {
- await this.consoleManager.setActiveInstance(wingfilePath);
- return;
- }
-
- // TODO: Use createConsoleApp from "bin-helper" instead of spawn to open the console after fixing after fixing https://github.com/winglang/wing/issues/3678
- if (!this.wingBin) {
- Loggers.default.appendLine(
- `Unable to open console: no wing binary found`
- );
- return;
- }
- const cp = spawn(
- this.wingBin,
- ["it", "--no-open", "--no-update-check", wingfilePath],
- {
- stdio: ["ignore", "pipe", "pipe"],
- windowsHide: true,
- shell: false,
- detached: process.platform !== "win32",
- env: {
- ...process.env,
- // Ask the Wing Console to not show the sign in prompt.
- NO_SIGN_IN: "true",
- },
- }
- );
-
- const onDidClose = () => {
- if (process.platform === "win32") {
- try {
- execSync(`taskkill /pid ${cp.pid} /T /F`);
- } catch (error) {
- Loggers.default.appendLine(
- `Failed to kill the process with taskkill: ${error}`
- );
-
- cp.kill();
- }
- } else {
- if (cp.pid) {
- process.kill(-cp.pid, "SIGTERM");
- }
- }
- };
-
- cp.on("error", async (err) => {
- Loggers.default.appendLine(err.toString());
- if (err) {
- Loggers.default.appendLine(`Wing Console Closed: ${err}`);
- this.consoleManager.closeInstance(wingfilePath);
- }
- });
- cp.stdout?.once("data", async (data) => {
- // get localhost url from stdout
- const urlMatch = data.toString().match(/localhost:\d+/);
- if (!urlMatch) {
- // there should be an error message in a different event
- return;
- }
- const url = urlMatch[0];
-
- await this.consoleManager.addInstance({
- id: wingfilePath,
- wingfile,
- url,
- client: createClient(url),
- onDidClose,
- });
- });
-
- process.once("exit", onDidClose);
- }
-
- public async openFile() {
- const activePanelId = this.consoleManager?.getActiveInstanceId();
- if (activePanelId) {
- const document = await workspace.openTextDocument(activePanelId);
-
- await window.showTextDocument(document);
- }
- }
-}
diff --git a/apps/vscode-wing/src/console/services/client.ts b/apps/vscode-wing/src/console/services/client.ts
deleted file mode 100644
index 67ecc00efdf..00000000000
--- a/apps/vscode-wing/src/console/services/client.ts
+++ /dev/null
@@ -1,133 +0,0 @@
-import {
- createTRPCProxyClient,
- httpLink,
- createWSClient,
- splitLink,
- wsLink,
-} from "@trpc/client";
-
-import type { ExplorerItem, Router, LogEntry } from "@wingconsole/server";
-
-import { EndpointItem } from "../explorer-providers/EndpointsExplorerProvider";
-import { TestItem } from "../explorer-providers/TestsExplorerProvider";
-
-export interface SubscriptionOptions {
- onData: (data: any) => void;
- onError: (error: any) => void;
-}
-
-export interface Client {
- url: string;
- getLogs: ({ time }: { time?: number }) => Promise;
- selectedNode: () => Promise;
- setSelectedNode: (resourcePath: string) => Promise;
- listTests: () => Promise;
- runTest: (resourcePath: string) => Promise;
- runAllTests: () => Promise;
- listResources: () => Promise;
- listEndpoints: () => Promise;
- onInvalidateQuery: (options: SubscriptionOptions) => void;
- onOpenFileInEditor: (options: SubscriptionOptions) => void;
- close: () => void;
-}
-
-export const createClient = (host: string): Client => {
- const url = `${host}/trpc`;
-
- const wsClient = createWSClient({
- url: `ws://${url}`,
- });
-
- const client = createTRPCProxyClient({
- links: [
- splitLink({
- condition(op) {
- return op.type === "subscription";
- },
- true: wsLink({
- client: wsClient,
- }),
- false: httpLink({
- url: `http://${url}`,
- }),
- }),
- ],
- });
-
- const getLogs = ({ time }: { time?: number }) => {
- return client["app.logs"].query({
- filters: {
- level: {
- verbose: true,
- info: true,
- warn: true,
- error: true,
- },
- text: "",
- timestamp: time || 0,
- },
- });
- };
-
- const selectedNode = () => {
- return client["app.selectedNode"].query();
- };
-
- const setSelectedNode = (resourcePath: string) => {
- return client["app.selectNode"].mutate({
- resourcePath,
- });
- };
-
- const listTests = (): Promise => {
- return client["test.list"].query();
- };
-
- const runTest = (resourcePath: string) => {
- return client["test.run"].mutate({
- resourcePath,
- });
- };
-
- const runAllTests = () => {
- return client["test.runAll"].mutate();
- };
-
- const listResources = () => {
- return client["app.explorerTree"].query();
- };
-
- const listEndpoints = (): Promise => {
- return client["endpoint.list"].query();
- };
-
- const onInvalidateQuery = (options: SubscriptionOptions) => {
- return client["app.invalidateQuery"].subscribe(undefined, options);
- };
-
- const onOpenFileInEditor = (options: SubscriptionOptions) => {
- return client["app.openFileInEditorSubscription"].subscribe(
- undefined,
- options
- );
- };
-
- const close = () => {
- wsClient.close();
- };
-
- return {
- url,
- getLogs,
- selectedNode,
- setSelectedNode,
- listTests,
- runTest,
- runAllTests,
- listResources,
- listEndpoints,
- onInvalidateQuery,
- onOpenFileInEditor,
- close,
- };
-};
diff --git a/apps/vscode-wing/src/constants.ts b/apps/vscode-wing/src/constants.ts
index e515ac8fcd4..4c9d22340bb 100644
--- a/apps/vscode-wing/src/constants.ts
+++ b/apps/vscode-wing/src/constants.ts
@@ -1,7 +1,6 @@
export const LANGUAGE_SERVER_NAME = "Wing Language Server";
export const LANGUAGE_SERVER_ID = "wing-language-server";
export const COMMAND_OPEN_CONSOLE = "wing.openConsole";
-export const COMMAND_OPEN_FILE = "wing.openFile";
+
export const CFG_WING = "wing";
export const CFG_WING_BIN = "bin";
-export const VIEW_TYPE_CONSOLE = "wing.console";
diff --git a/apps/vscode-wing/src/extension.ts b/apps/vscode-wing/src/extension.ts
index fd355b34ba6..aa5bb410eb1 100644
--- a/apps/vscode-wing/src/extension.ts
+++ b/apps/vscode-wing/src/extension.ts
@@ -7,13 +7,11 @@ import {
window,
} from "vscode";
import { getWingBin, updateStatusBar } from "./bin-helper";
-import { WingConsoleManager } from "./console";
-import { CFG_WING, CFG_WING_BIN } from "./constants";
+import { CFG_WING, CFG_WING_BIN, COMMAND_OPEN_CONSOLE } from "./constants";
import { Loggers } from "./logging";
import { LanguageServerManager } from "./lsp";
let wingBinWatcher: FSWatcher | undefined;
-let wingConsoleContext: WingConsoleManager | undefined;
let languageServerManager: LanguageServerManager | undefined;
export async function deactivate() {
@@ -29,7 +27,6 @@ export async function activate(context: ExtensionContext) {
wordPattern: /([a-zA-Z_$][A-Za-z_$0-9]*)/,
});
- wingConsoleContext = new WingConsoleManager(context);
languageServerManager = new LanguageServerManager();
const wingBinChanged = async () => {
@@ -56,24 +53,8 @@ export async function activate(context: ExtensionContext) {
Loggers.default.appendLine(`Using wing from "${currentWingBin}"`);
languageServerManager?.setWingBin(currentWingBin);
- wingConsoleContext?.setWingBin(currentWingBin);
await languageServerManager?.start();
-
- // restart the language server and reset any open console windows
- if (wingConsoleContext?.consoleManager?.activeInstances()) {
- const chooseReload = await window.showInformationMessage(
- `Wing has been updated and there are open consoles. Would you like to close them? (This will reset their state)`,
- "Yes",
- "No (Close and reopen console to use new version)"
- );
-
- if (chooseReload === "Yes") {
- await wingConsoleContext?.stop();
- }
- } else {
- await wingConsoleContext?.stop();
- }
} else {
void window.showErrorMessage(`wing not found at "${currentWingBin}"`);
}
@@ -82,6 +63,24 @@ export async function activate(context: ExtensionContext) {
}
};
+ const wingIt = async () => {
+ const filePath = window.activeTextEditor?.document.fileName;
+ if (!filePath) {
+ return;
+ }
+ const terminalName = `Wing it: ${filePath.split("/").pop()}`;
+
+ const existingTerminal = window.terminals.find(
+ (t) => t.name === terminalName
+ );
+ if (existingTerminal) {
+ existingTerminal.dispose();
+ }
+ const terminal = window.createTerminal(terminalName);
+ terminal.show();
+ terminal.sendText(`wing it "${filePath}"`);
+ };
+
//watch for config changes
workspace.onDidChangeConfiguration(async (e) => {
// see if WING_BIN has changed
@@ -92,12 +91,7 @@ export async function activate(context: ExtensionContext) {
// add command to preview wing files
context.subscriptions.push(
- commands.registerCommand("wing.openFile", () =>
- wingConsoleContext?.openFile()
- ),
- commands.registerCommand("wing.openConsole", () =>
- wingConsoleContext?.openConsole()
- )
+ commands.registerCommand(COMMAND_OPEN_CONSOLE, wingIt)
);
await wingBinChanged();
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 06538b7982d..565760cad05 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -188,12 +188,6 @@ importers:
'@vscode/vsce':
specifier: ^2.21.0
version: 2.21.1
- '@wingconsole/app':
- specifier: workspace:^
- version: link:../wing-console/console/app
- '@wingconsole/server':
- specifier: workspace:^
- version: link:../wing-console/console/server
eslint:
specifier: ^8
version: 8.51.0