diff --git a/.gitignore b/.gitignore index 1ba5d5cd..d0479b12 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,15 @@ .DS_Store Thumbs.db .vscode/ +.vscode-test/ .idea/ -.sass-cache .eslintcache lib-cov *.log +*.log* pids -.vscode-test/ - +# Node .npm/ node_modules/ package-lock.json @@ -20,9 +20,7 @@ dist/ out/ build/ *.tsbuildinfo - .history/ -*.log* # env .env diff --git a/.vscodeignore b/.vscodeignore index a4b3966a..fa9763b0 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -10,5 +10,6 @@ vsc-extension-quickstart.md **/tsconfig.json **/.eslintrc.json **/*.map +**/*.js.map **/*.ts -**/.vscode-test.* +**/.vscode-test.* \ No newline at end of file diff --git a/package.json b/package.json index b13face7..dd9bfd4d 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "zenml-studio", + "publisher": "zenml", "displayName": "ZenML Studio", "description": "", "version": "0.0.1", @@ -33,17 +34,19 @@ "test": "vscode-test" }, "devDependencies": { - "@types/vscode": "^1.86.0", "@types/mocha": "^10.0.6", "@types/node": "18.x", + "@types/vscode": "^1.86.0", + "@types/webpack": "^5.28.5", "@typescript-eslint/eslint-plugin": "^6.19.1", "@typescript-eslint/parser": "^6.19.1", + "@vscode/test-cli": "^0.0.4", + "@vscode/test-electron": "^2.3.9", "eslint": "^8.56.0", - "typescript": "^5.3.3", + "resolve-ts-aliases": "^1.0.1", "ts-loader": "^9.5.1", + "typescript": "^5.3.3", "webpack": "^5.90.0", - "webpack-cli": "^5.1.4", - "@vscode/test-cli": "^0.0.4", - "@vscode/test-electron": "^2.3.9" + "webpack-cli": "^5.1.4" } } diff --git a/src/commands/stackCommands.ts b/src/commands/stackCommands.ts index 4bfb5de9..c448a504 100644 --- a/src/commands/stackCommands.ts +++ b/src/commands/stackCommands.ts @@ -1,8 +1,12 @@ -import { execCLICommand } from '../utils/shell'; +import { Shell } from '../utils/shell'; /** * Fetches the current active stack using the ZenML CLI. + * + * @param {Function} execCLICommand - Optional. Custom function to execute CLI commands, intended + * for testing with mocks or stubs. + * @returns {Promise} Promise resolving with the name of the current active stack. */ -export function getActiveStack(): Promise { - return execCLICommand('zenml stack get'); +export async function getActiveStack(execCLICommand: Function = Shell.execCLICommand): Promise { + return await execCLICommand('zenml stack get'); } diff --git a/src/test/extension.test.ts b/src/test/extension.test.ts index 4ca0ab41..498ad772 100644 --- a/src/test/extension.test.ts +++ b/src/test/extension.test.ts @@ -1,15 +1,18 @@ 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('Extension should be present', () => { + assert.ok(vscode.extensions.getExtension('zenml.zenml-studio')); + }); - test('Sample test', () => { - assert.strictEqual(-1, [1, 2, 3].indexOf(5)); - assert.strictEqual(-1, [1, 2, 3].indexOf(0)); + test('Extension should activate', async () => { + const extension = vscode.extensions.getExtension('zenml.zenml-studio'); + if (extension) { + await extension.activate(); + assert.ok(extension.isActive, 'Extension did not activate as expected.'); + } else { + assert.fail('Extension zenml-studio could not be found.'); + } }); }); diff --git a/src/utils/shell.ts b/src/utils/shell.ts index a040f99e..6f7b0bfb 100644 --- a/src/utils/shell.ts +++ b/src/utils/shell.ts @@ -1,17 +1,18 @@ import { exec } from 'child_process'; -/** - * Executes a CLI command and returns a promise that resolves with the command's stdout. - */ -export function execCLICommand(command: string): Promise { - return new Promise((resolve, reject) => { - - exec(command, (error, stdout, stderr) => { - if (error) { - reject(error); - return; - } - resolve(stdout.trim()); +export class Shell { + /** + * Executes a CLI command and returns a promise that resolves with the command's stdout. + */ + static execCLICommand(command: string): Promise { + return new Promise((resolve, reject) => { + exec(command, (error, stdout, stderr) => { + if (error) { + reject(error); + return; + } + resolve(stdout.trim()); + }); }); - }); + } } diff --git a/src/views/statusBar.ts b/src/views/statusBar.ts index fbc5e179..1f4d1106 100644 --- a/src/views/statusBar.ts +++ b/src/views/statusBar.ts @@ -36,13 +36,13 @@ export class ZenMLStatusBar { public updateStatusBar() { console.log('Updating ZenML active stack...'); - getActiveStack().then((fullActiveStackText) => { + getActiveStack().then((activeStackCliOutput) => { /** * The cli command `zenml stack get` outputs the line below: * The global active stack is: 'default' * 'default' is the actual string we want to display in the status bar. */ - const match = fullActiveStackText.match(/'([^']+)'/); // matches text within single quotes + const match = activeStackCliOutput.match(/'([^']+)'/); // matches text within single quotes const activeStack = match ? match[1] : 'Error parsing stack name'; this.statusBar.text = `Active Stack: ${activeStack}`; this.statusBar.tooltip = 'Click to refresh the active ZenML stack'; diff --git a/tsconfig.json b/tsconfig.json index 8a79f20f..934a5b6f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,10 +7,9 @@ ], "sourceMap": true, "rootDir": "src", - "strict": true /* enable all strict type-checking options */ - /* Additional Checks */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - } + "strict": true, + "skipLibCheck": true, + }, + "exclude": ["node_modules"], + "include": ["./src/**/*.ts"] }