it builds again

This commit is contained in:
Michael Becker 2024-08-31 20:37:49 -04:00
parent 131ad9cd24
commit c1558c1ca2
13 changed files with 1260 additions and 524 deletions

5
.vscode-test.mjs Normal file
View File

@ -0,0 +1,5 @@
import { defineConfig } from '@vscode/test-cli';
export default defineConfig({
files: 'out/test/**/*.test.js',
});

View File

@ -2,6 +2,7 @@
// See http://go.microsoft.com/fwlink/?LinkId=827846 // See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format // for the documentation about the extensions.json format
"recommendations": [ "recommendations": [
"dbaeumer.vscode-eslint" "dbaeumer.vscode-eslint",
"ms-vscode.extension-test-runner"
] ]
} }

13
.vscode/launch.json vendored
View File

@ -16,19 +16,6 @@
"${workspaceFolder}/out/**/*.js" "${workspaceFolder}/out/**/*.js"
], ],
"preLaunchTask": "${defaultBuildTask}" "preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
} }
] ]
} }

18
.vscode/settings.json vendored
View File

@ -1,11 +1,11 @@
// Place your settings in this file to overwrite default and user settings. // Place your settings in this file to overwrite default and user settings.
{ {
"files.exclude": { "files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files "out": false // set this to true to hide the "out" folder with the compiled JS files
}, },
"search.exclude": { "search.exclude": {
"out": true // set this to false to include "out" folder in search results "out": true // set this to false to include "out" folder in search results
}, },
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts // Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off" "typescript.tsc.autoDetect": "off"
} }

View File

@ -8,3 +8,4 @@ vsc-extension-quickstart.md
**/.eslintrc.json **/.eslintrc.json
**/*.map **/*.map
**/*.ts **/*.ts
**/.vscode-test.*

View File

@ -1,6 +1,6 @@
# Change Log # Change Log
All notable changes to the "suvmanager" extension will be documented in this file. All notable changes to the "mocha-vscode" extension will be documented in this file.
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

View File

@ -1,21 +1,25 @@
# mocha-vscode # mocha-vscode README
This is the VSCode/VSCodium extension for directly interfacing with Mocha Advanced Database Infrastructure systems from within the IDE. This is the README for your extension "mocha-vscode". After writing up a brief description, we recommend including the following sections.
## Features ## Features
* Access instances, attributes, and relationships directly from a MADI server as YAML / ZQ definitions
* Remotely spin up, shut down, and manage tenants on provisioned Single User Virtual Machines (SUVs) Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file.
For example if there is an image subfolder under your extension project workspace:
\!\[feature X\]\(images/feature-x.png\)
> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow.
## Requirements ## Requirements
* This extension makes heavy use of the Mocha command line utility. Please make sure that is installed in /usr/bin/mocha and /usr/lib/mocha. If you have any requirements or dependencies, add a section describing those and how to install and configure them.
* To provision and maintain Single User Virtual Machines (SUVs), VirtualBox and Vagrant must be installed on your local machine. Support for remote administration is planned but not implemented at this time.
## Extension Settings ## Extension Settings
This extension does not add any VS Code settings through the `contributes.configuration` extension point (yet!) Include if your extension adds any VS Code settings through the `contributes.configuration` extension point.
<!--
For example: For example:
This extension contributes the following settings: This extension contributes the following settings:
@ -23,18 +27,45 @@ This extension contributes the following settings:
* `myExtension.enable`: Enable/disable this extension. * `myExtension.enable`: Enable/disable this extension.
* `myExtension.thing`: Set to `blah` to do something. * `myExtension.thing`: Set to `blah` to do something.
-->
## Known Issues ## Known Issues
Nothing works yet. This is being addressed and hopefully a fix will be issued soon. Calling out known issues can help limit users opening duplicate issues against your extension.
## Release Notes ## Release Notes
### 0.0.1 Users appreciate release notes as you update your extension.
Initial release of Mocha-VSCode. ### 1.0.0
Initial release of ...
### 1.0.1
Fixed issue #.
### 1.1.0
Added features X, Y, and Z.
--- ---
## Following extension guidelines
Ensure that you've read through the extensions guidelines and follow the best practices for creating your extension.
* [Extension Guidelines](https://code.visualstudio.com/api/references/extension-guidelines)
## Working with Markdown
You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:
* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux).
* Toggle preview (`Shift+Cmd+V` on macOS or `Shift+Ctrl+V` on Windows and Linux).
* Press `Ctrl+Space` (Windows, Linux, macOS) to see a list of Markdown snippets.
## For more information
* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown)
* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/)
**Enjoy!** **Enjoy!**

1516
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,10 @@
{ {
"name": "mochacodium", "name": "mocha-vscode",
"displayName": "Mocha VSCodium Extension", "displayName": "Mocha for VSCode",
"description": "Manage Mocha SUVs and interact with ZQ from your IDE", "description": "Tools for working with the Mocha Advanced Database Infrastructure platform",
"version": "0.0.1", "version": "0.0.1",
"engines": { "engines": {
"vscode": "^1.84.0" "vscode": "^1.92.0"
}, },
"categories": [ "categories": [
"Other" "Other"
@ -27,10 +27,10 @@
"command": "mocha.suvmanager.suv_new", "command": "mocha.suvmanager.suv_new",
"title": "Provision New SUV", "title": "Provision New SUV",
"category": "Mocha", "category": "Mocha",
"icon": { "icon": {
"light": "icons/commands/add-connection-light.svg", "light": "icons/commands/add-connection-light.svg",
"dark": "icons/commands/add-connection-dark.svg" "dark": "icons/commands/add-connection-dark.svg"
} }
}, },
{ {
"command": "mocha.add_documentation_comment", "command": "mocha.add_documentation_comment",
@ -69,6 +69,7 @@
}, },
{ {
"command": "mocha.zq_open_document", "command": "mocha.zq_open_document",
"title": "Open ZQ Document",
"enablement": "never", "enablement": "never",
"category": "Mocha" "category": "Mocha"
}, },
@ -138,12 +139,12 @@
] ]
}, },
"menus": { "menus": {
"view/title": [ "view/title": [
{ {
"command": "mocha.suvmanager.suv_new", "command": "mocha.suvmanager.suv_new",
"when": "view == mocha.suvManager", "when": "view == mocha.suvManager",
"group": "navigation@1" "group": "navigation@1"
} }
] ]
} }
}, },
@ -153,18 +154,17 @@
"watch": "tsc -watch -p ./", "watch": "tsc -watch -p ./",
"pretest": "npm run compile && npm run lint", "pretest": "npm run compile && npm run lint",
"lint": "eslint src --ext ts", "lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js" "test": "vscode-test"
}, },
"devDependencies": { "devDependencies": {
"@types/vscode": "^1.84.0", "@types/vscode": "^1.92.0",
"@types/mocha": "^10.0.3", "@types/mocha": "^10.0.7",
"@types/node": "18.x", "@types/node": "20.x",
"@typescript-eslint/eslint-plugin": "^6.9.0", "@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^6.9.0", "@typescript-eslint/parser": "^7.11.0",
"eslint": "^8.52.0", "eslint": "^8.57.0",
"glob": "^10.3.10", "typescript": "^5.4.5",
"mocha": "^10.2.0", "@vscode/test-cli": "^0.0.9",
"typescript": "^5.2.2", "@vscode/test-electron": "^2.4.0"
"@vscode/test-electron": "^2.3.6"
} }
} }

View File

@ -4,7 +4,7 @@ import * as path from 'path';
import { Machine } from './Machine'; import { Machine } from './Machine';
const cp = require('child_process') const cp = require('child_process');
export class SuvManagerTreeDataProvider implements vscode.TreeDataProvider<Machine> { export class SuvManagerTreeDataProvider implements vscode.TreeDataProvider<Machine> {
@ -18,6 +18,15 @@ export class SuvManagerTreeDataProvider implements vscode.TreeDataProvider<Machi
{ {
this._treeview = v; this._treeview = v;
} }
private changeEvent = new vscode.EventEmitter<void>();
refresh() : void {
this.changeEvent.fire();
}
public get onDidChangeTreeData() : vscode.Event<void> {
return this.changeEvent.event;
}
getTreeItem(element: Machine): vscode.TreeItem { getTreeItem(element: Machine): vscode.TreeItem {
@ -36,10 +45,10 @@ export class SuvManagerTreeDataProvider implements vscode.TreeDataProvider<Machi
cp.exec('mocha suv list', (err: string, stdout: string, stderr: string) => cp.exec('mocha suv list', (err: string, stdout: string, stderr: string) =>
{ {
let listSuvs = new Array<Machine>(); let listSuvs = new Array<Machine>();
let list = stdout.split(' '); let list = stdout.split('\n');
if (list.length == 0) if (list.length === 0)
{ {
if (this.treeview != null) if (this.treeview !== null)
{ {
this.treeview.message = "No items to show here"; this.treeview.message = "No items to show here";
this.treeview.badge = { "value": 0, "tooltip": "No SUVs available" }; this.treeview.badge = { "value": 0, "tooltip": "No SUVs available" };
@ -51,21 +60,26 @@ export class SuvManagerTreeDataProvider implements vscode.TreeDataProvider<Machi
list.forEach( (element) => list.forEach( (element) =>
{ {
if (element == "")
{
return;
}
let m1 = new Machine(); let m1 = new Machine();
m1.name = element.trim(); m1.name = element.trim();
ct ++; ct ++;
listSuvs.push(m1); listSuvs.push(m1);
}); });
if (this.treeview != null) if (this.treeview !== null)
{ {
this.treeview.badge = { "value": ct, "tooltip": ct.toString() + " SUV(s) running" }; this.treeview.badge = { "value": ct, "tooltip": ct.toString() + " SUV(s) running" };
} }
} }
resolve(listSuvs); resolve(listSuvs);
}); });
}) });
} }
return Promise.resolve([]); return Promise.resolve([]);
} }

View File

@ -7,12 +7,17 @@ import { GenericTreeDataProvider } from './tdp/GenericTreeDataProvider';
import { GenericTreeDataItem } from './tdp/GenericTreeDataItem'; import { GenericTreeDataItem } from './tdp/GenericTreeDataItem';
import { ModuleExplorerTreeDataProvider } from './ModuleExplorerTreeDataProvider'; import { ModuleExplorerTreeDataProvider } from './ModuleExplorerTreeDataProvider';
import { userInfo } from 'os'; import { userInfo } from 'os';
import { Machine } from './Machine';
import * as path from 'path'; import * as path from 'path';
import https from 'node:https'; import https from 'node:https';
const cp = require('child_process'); const cp = require('child_process');
let dpModuleExplorer = new ModuleExplorerTreeDataProvider();
let treeSuvManager : vscode.TreeView<Machine> | undefined = undefined;
export function mkotsuri(suvId : string, tenantName : string, command : string, serviceName : string = "zq", version : string = "v1") : vscode.Uri export function mkotsuri(suvId : string, tenantName : string, command : string, serviceName : string = "zq", version : string = "v1") : vscode.Uri
{ {
let otsUri = vscode.Uri.parse("https://" + suvId + ".privatesuv.com/ots/" + tenantName + "/services/" + serviceName + "/" + version + "/" + command); let otsUri = vscode.Uri.parse("https://" + suvId + ".privatesuv.com/ots/" + tenantName + "/services/" + serviceName + "/" + version + "/" + command);
@ -20,7 +25,6 @@ export function mkotsuri(suvId : string, tenantName : string, command : string,
} }
function updateModuleExplorerTreeView() { function updateModuleExplorerTreeView() {
let dpModuleExplorer = new ModuleExplorerTreeDataProvider();
/* /*
dpModuleExplorer.items.push(new GenericTreeDataItem("tools", "tools", [ dpModuleExplorer.items.push(new GenericTreeDataItem("tools", "tools", [
new GenericTreeDataItem("tools:xpresso", "xpressO", [ new GenericTreeDataItem("tools:xpresso", "xpressO", [
@ -44,21 +48,26 @@ function updateModuleExplorerTreeView() {
} }
)); ));
*/ */
let suvId : string = "i-0c0398f84acecb702"; let suvId : string = "i-0c0398f84acecb702";
let tenantName : string = "super"; let tenantName : string = "super";
let otsuri = mkotsuri(suvId, tenantName, "module/list"); let otsuri = mkotsuri(suvId, tenantName, "module/list");
cp.exec("curl " + otsuri.toString(), (err: string, stdout: string, stderr: string) => cp.exec("curl " + otsuri.toString(), (err: string, stdout: string, stderr: string) =>
{ {
if (err != "")
{
vscode.window.showErrorMessage(err);
}
let json = JSON.parse(stdout); let json = JSON.parse(stdout);
for (var i = 0; i < json.items.length; i++) for (var i = 0; i < json.items.length; i++)
{2 {
recursiveAddItemToTreeView(dpModuleExplorer, json.items[i], null); recursiveAddItemToTreeView(dpModuleExplorer, json.items[i], null);
} }
//dpModuleExplorer.refresh(); dpModuleExplorer.refresh();
let treeModuleExplorer = vscode.window.createTreeView("mocha.moduleExplorer", { "canSelectMany": true, "showCollapseAll": true, "treeDataProvider": dpModuleExplorer }); //let treeModuleExplorer = vscode.window.createTreeView("mocha.moduleExplorer", { "canSelectMany": true, "showCollapseAll": true, "treeDataProvider": dpModuleExplorer });
//console.log(stdout); //console.log(stdout);
}); });
} }
@ -98,11 +107,16 @@ function recursiveAddItemToTreeView(dp : GenericTreeDataProvider, item : any, pa
export function activate(context: vscode.ExtensionContext) { export function activate(context: vscode.ExtensionContext) {
let treeDataProvider = new SuvManagerTreeDataProvider(); let treeDataProvider = new SuvManagerTreeDataProvider();
let treeSuvManager = vscode.window.createTreeView("mocha.suvManager", { "canSelectMany": true, "showCollapseAll": true, "treeDataProvider": treeDataProvider }); treeSuvManager = vscode.window.createTreeView("mocha.suvManager", { "canSelectMany": true, "showCollapseAll": true, "treeDataProvider": treeDataProvider });
treeDataProvider.treeview = treeSuvManager; treeDataProvider.treeview = treeSuvManager;
treeSuvManager.badge = { "value": 1, "tooltip": "1 SUV(s) running" }; treeSuvManager.badge = { "value": 1, "tooltip": "1 SUV(s) running" };
let treeModuleExplorer = vscode.window.createTreeView("mocha.moduleExplorer", { "canSelectMany": true, "showCollapseAll": true, "treeDataProvider": dpModuleExplorer });
// dpModuleExplorer.treeview = treeModuleExplorer;
// treeModuleExplorer.badge = { "value": 1, "tooltip": "1 SUV(s) running" };
updateModuleExplorerTreeView(); // updateModuleExplorerTreeView();
// Use the console to output diagnostic information (console.log) and errors (console.error) // Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated // This line of code will only be executed once when your extension is activated
@ -207,6 +221,7 @@ export function activate(context: vscode.ExtensionContext) {
// Display a message box to the user // Display a message box to the user
cp.exec('mocha suv list', (err: string, stdout: string, stderr: string) => cp.exec('mocha suv list', (err: string, stdout: string, stderr: string) =>
{ {
vscode.window.showInformationMessage(stdout);
let list = stdout.split(' '); let list = stdout.split(' ');
let list2 = new Array<string>(); let list2 = new Array<string>();
list.forEach( (element) => list.forEach( (element) =>
@ -224,8 +239,42 @@ export function activate(context: vscode.ExtensionContext) {
}); });
}); });
}); });
let cmd_suv_new = vscode.commands.registerCommand('mocha.suvmanager.suv_new', () => {
cp.exec('mocha suv new --unattended', (err: string, stdout: string, stderr: string) =>
{
vscode.window.showInformationMessage('New SUV provisioned successfully!');
treeDataProvider.refresh();
});
});
context.subscriptions.push(cmd_suv_up); context.subscriptions.push(cmd_suv_up);
} }
// This method is called when your extension is deactivated // This method is called when your extension is deactivated
export function deactivate() {} export function deactivate() {}
/*
// This method is called when your extension is activated
// Your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {
// Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated
console.log('Blah blah the blah blah!');
// The command has been defined in the package.json file
// Now provide the implementation of the command with registerCommand
// The commandId parameter must match the command field in package.json
const disposable = vscode.commands.registerCommand('mocha-vscode.helloWorld', () => {
// The code you place here will be executed every time your command is executed
// Display a message box to the user
vscode.window.showInformationMessage('Blah blah the blah blah!');
});
context.subscriptions.push(disposable);
}
// This method is called when your extension is deactivated
export function deactivate() {}
*/

View File

@ -0,0 +1,15 @@
import * as assert from 'assert';
// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
import * as vscode from 'vscode';
// import * as myExtension from '../../extension';
suite('Extension Test Suite', () => {
vscode.window.showInformationMessage('Start all tests.');
test('Sample test', () => {
assert.strictEqual(-1, [1, 2, 3].indexOf(5));
assert.strictEqual(-1, [1, 2, 3].indexOf(0));
});
});

View File

@ -27,16 +27,17 @@
## Run tests ## Run tests
* Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Extension Tests`. * Install the [Extension Test Runner](https://marketplace.visualstudio.com/items?itemName=ms-vscode.extension-test-runner)
* Press `F5` to run the tests in a new window with your extension loaded. * Run the "watch" task via the **Tasks: Run Task** command. Make sure this is running, or tests might not be discovered.
* See the output of the test result in the debug console. * Open the Testing view from the activity bar and click the Run Test" button, or use the hotkey `Ctrl/Cmd + ; A`
* Make changes to `src/test/suite/extension.test.ts` or create new test files inside the `test/suite` folder. * See the output of the test result in the Test Results view.
* Make changes to `src/test/extension.test.ts` or create new test files inside the `test` folder.
* The provided test runner will only consider files matching the name pattern `**.test.ts`. * The provided test runner will only consider files matching the name pattern `**.test.ts`.
* You can create folders inside the `test` folder to structure your tests any way you want. * You can create folders inside the `test` folder to structure your tests any way you want.
## Go further ## Go further
* [Follow UX guidelines](https://code.visualstudio.com/api/ux-guidelines/overview) to create extensions that seamlessly integrate with VS Code's native interface and patterns. * [Follow UX guidelines](https://code.visualstudio.com/api/ux-guidelines/overview) to create extensions that seamlessly integrate with VS Code's native interface and patterns.
* Reduce the extension size and improve the startup time by [bundling your extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension). * Reduce the extension size and improve the startup time by [bundling your extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension).
* [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VS Code extension marketplace. * [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VS Code extension marketplace.
* Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration). * Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration).