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
// for the documentation about the extensions.json format
"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"
],
"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}"
}
]
}

View File

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

View File

@ -1,6 +1,6 @@
# 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.

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
* 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
* 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.
* 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.
If you have any requirements or dependencies, add a section describing those and how to install and configure them.
## 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:
This extension contributes the following settings:
@ -23,18 +27,45 @@ This extension contributes the following settings:
* `myExtension.enable`: Enable/disable this extension.
* `myExtension.thing`: Set to `blah` to do something.
-->
## 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
### 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!**

1512
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -4,7 +4,7 @@ import * as path from 'path';
import { Machine } from './Machine';
const cp = require('child_process')
const cp = require('child_process');
export class SuvManagerTreeDataProvider implements vscode.TreeDataProvider<Machine> {
@ -19,6 +19,15 @@ export class SuvManagerTreeDataProvider implements vscode.TreeDataProvider<Machi
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 {
return new vscode.TreeItem(element.name);
@ -36,10 +45,10 @@ export class SuvManagerTreeDataProvider implements vscode.TreeDataProvider<Machi
cp.exec('mocha suv list', (err: string, stdout: string, stderr: string) =>
{
let listSuvs = new Array<Machine>();
let list = stdout.split(' ');
if (list.length == 0)
let list = stdout.split('\n');
if (list.length === 0)
{
if (this.treeview != null)
if (this.treeview !== null)
{
this.treeview.message = "No items to show here";
this.treeview.badge = { "value": 0, "tooltip": "No SUVs available" };
@ -51,6 +60,11 @@ export class SuvManagerTreeDataProvider implements vscode.TreeDataProvider<Machi
list.forEach( (element) =>
{
if (element == "")
{
return;
}
let m1 = new Machine();
m1.name = element.trim();
ct ++;
@ -58,14 +72,14 @@ export class SuvManagerTreeDataProvider implements vscode.TreeDataProvider<Machi
listSuvs.push(m1);
});
if (this.treeview != null)
if (this.treeview !== null)
{
this.treeview.badge = { "value": ct, "tooltip": ct.toString() + " SUV(s) running" };
}
}
resolve(listSuvs);
});
})
});
}
return Promise.resolve([]);
}

View File

@ -7,12 +7,17 @@ import { GenericTreeDataProvider } from './tdp/GenericTreeDataProvider';
import { GenericTreeDataItem } from './tdp/GenericTreeDataItem';
import { ModuleExplorerTreeDataProvider } from './ModuleExplorerTreeDataProvider';
import { userInfo } from 'os';
import { Machine } from './Machine';
import * as path from 'path';
import https from 'node:https';
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
{
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() {
let dpModuleExplorer = new ModuleExplorerTreeDataProvider();
/*
dpModuleExplorer.items.push(new GenericTreeDataItem("tools", "tools", [
new GenericTreeDataItem("tools:xpresso", "xpressO", [
@ -44,21 +48,26 @@ function updateModuleExplorerTreeView() {
}
));
*/
let suvId : string = "i-0c0398f84acecb702";
let tenantName : string = "super";
let otsuri = mkotsuri(suvId, tenantName, "module/list");
cp.exec("curl " + otsuri.toString(), (err: string, stdout: string, stderr: string) =>
{
if (err != "")
{
vscode.window.showErrorMessage(err);
}
let json = JSON.parse(stdout);
for (var i = 0; i < json.items.length; i++)
{2
{
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);
});
}
@ -98,11 +107,16 @@ function recursiveAddItemToTreeView(dp : GenericTreeDataProvider, item : any, pa
export function activate(context: vscode.ExtensionContext) {
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;
treeSuvManager.badge = { "value": 1, "tooltip": "1 SUV(s) running" };
updateModuleExplorerTreeView();
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();
// 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
@ -207,6 +221,7 @@ export function activate(context: vscode.ExtensionContext) {
// Display a message box to the user
cp.exec('mocha suv list', (err: string, stdout: string, stderr: string) =>
{
vscode.window.showInformationMessage(stdout);
let list = stdout.split(' ');
let list2 = new Array<string>();
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);
}
// This method is called when your extension is deactivated
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,10 +27,11 @@
## Run tests
* Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Extension Tests`.
* Press `F5` to run the tests in a new window with your extension loaded.
* See the output of the test result in the debug console.
* Make changes to `src/test/suite/extension.test.ts` or create new test files inside the `test/suite` folder.
* Install the [Extension Test Runner](https://marketplace.visualstudio.com/items?itemName=ms-vscode.extension-test-runner)
* Run the "watch" task via the **Tasks: Run Task** command. Make sure this is running, or tests might not be discovered.
* Open the Testing view from the activity bar and click the Run Test" button, or use the hotkey `Ctrl/Cmd + ; A`
* 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`.
* You can create folders inside the `test` folder to structure your tests any way you want.