Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- run: mkdir -p packages/databricks-vscode/artifacts

- name: Build VSIX
run: yarn workspace databricks package -o artifacts -t darwin-x64
run: yarn workspace databricks-vscode package -o artifacts -t darwin-x64

- name: Upload artifacts
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jobs:
timeout_minutes: 10
retry_on: any
command: |
yarn workspace databricks run test:integ:clean
yarn workspace databricks-vscode run test:integ:clean
yarn install --immutable
yarn build
cd packages/databricks-vscode
Expand Down
4 changes: 4 additions & 0 deletions databricks-vscode.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
{
"path": "packages/databricks-vscode",
"name": "Extension"
},
{
"path": "packages/databricks-vscode-types",
"name": "Extension Types"
}
],
"settings": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "databricks-vscode",
"name": "@databricks/databricks-vscode",
"version": "0.0.1",
"private": true,
"workspaces": [
Expand Down
2 changes: 2 additions & 0 deletions packages/databricks-vscode-types/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
index.d.ts
index.js
58 changes: 58 additions & 0 deletions packages/databricks-vscode-types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Databricks Extension for VSCode Interfaces and Types

Package with types and interfaces required for extending the Databricks VSCode extension.

## How to extend the Databricks VSCode extension

### Importing and using the API

package.json

```json
{
...
"extensionDependencies": [
"databricks.databricks-vscode"
],
"devDependencies": {
...
"@databricks/databricks-vscode-types": "*",
}
}
```

src/extension.ts

```js
import {PublicApi} from "@databricks/databricks-vscode-types";

export async function activate(context: vscode.ExtensionContext) {
const dbExtension =
extensions.getExtension < PublicApi > "databricks.databricks-vscode";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still needs brackets?

Suggested change
extensions.getExtension < PublicApi > "databricks.databricks-vscode";
extensions.getExtension < PublicApi > ("databricks.databricks-vscode");


if (!dbExtension) {
throw new Error("Databricks extension not installed");
}
await dbExtension.activate();
const dbApi = dbExtension.exports;
//...
}
```

### Adding a view to the Databricks activity bar

```js
"contributes" {
// ...
"views": {
"databricksBar": [
{
"id": "databricksJobs",
"name": "Jobs"
},
// ...
],
// ...
}
}
```
18 changes: 18 additions & 0 deletions packages/databricks-vscode-types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {ApiClient} from "@databricks/databricks-sdk";
import {Cluster} from "@databricks/databricks-sdk";
import {Event} from "vscode";
export type ConnectionState = "CONNECTED" | "CONNECTING" | "DISCONNECTED";

export interface PublicApi {
connectionManager: {
onDidChangeState: Event<ConnectionState>;

get profile(): string | undefined;
get me(): string | undefined;
get state(): ConnectionState;
get cluster(): Cluster | undefined;
get apiClient(): ApiClient | undefined;

waitForConnect(): Promise<void>;
};
}
27 changes: 27 additions & 0 deletions packages/databricks-vscode-types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@databricks/databricks-vscode-types",
"version": "1.0.0",
"description": "Package with types and interfaces to develop extensions to the Databricks VSCode plugin",
"main": "index.js",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/databricks/databricks-vscode.git"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/databricks/databricks-vscode/issues"
},
"homepage": "https://github.com/databricks/databricks-vscode#readme",
"scripts": {
"build": "tsc",
"watch": "tsc -w"
},
"devDependencies": {
"@types/vscode": "^1.69.1",
"typescript": "^4.8.3"
},
"dependencies": {
"@databricks/databricks-sdk": "workspace:^"
}
}
13 changes: 13 additions & 0 deletions packages/databricks-vscode-types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "CommonJS",
"target": "ES2020",
"declaration": true,
"esModuleInterop": true,
"isolatedModules": true,
"lib": ["ES2020", "ES2021.String"],
"rootDir": ".",
"strict": true /* enable all strict type-checking options */
},
"include": ["*.ts"]
}
8 changes: 5 additions & 3 deletions packages/databricks-vscode/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "databricks",
"name": "databricks-vscode",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to update workspace names in the manual workflow for integration tests in internal repo as well.

Adding a ticket for that

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

"displayName": "Databricks for Visual Studio Code",
"description": "IDE support for Databricks",
"publisher": "databricks",
Expand Down Expand Up @@ -64,6 +64,7 @@
"onDebugResolve:databricks-workflow"
],
"main": "out/extension.js",
"types": "out/extension.d.ts",
"contributes": {
"commands": [
{
Expand Down Expand Up @@ -452,7 +453,7 @@
"test:unit": "yarn run build && node ./out/test/runTest.js",
"test:integ:clean": "yarn run clean && rm -rf /tmp/vscode-test-databricks /tmp/databricks-vscode-test-extensions",
"test:integ:prepare": "CODE_VERSION=1.69.1 && yarn run package && extest get-vscode --code_version $CODE_VERSION --storage /tmp/vscode-test-databricks && extest get-chromedriver --code_version 1.69.1 --storage /tmp/vscode-test-databricks",
"test:integ:install-vsix": "extest install-vsix --storage /tmp/vscode-test-databricks -f databricks-0.0.1.vsix -e /tmp/databricks-vscode-test-extensions",
"test:integ:install-vsix": "extest install-vsix --storage /tmp/vscode-test-databricks -f databricks-vscode*.vsix -e /tmp/databricks-vscode-test-extensions",
"test:integ:run": "yarn run build && node out/test/e2e/scripts/e2e.js -e /tmp/databricks-vscode-test-extensions --storage /tmp/vscode-test-databricks --code_settings src/test/e2e/settings.json 'out/**/*.e2e.js'",
"test:integ": "yarn run test:integ:prepare && yarn run test:integ:install-vsix && yarn run test:integ:run",
"test:cov": "nyc yarn run test:unit",
Expand All @@ -461,6 +462,7 @@
},
"dependencies": {
"@databricks/databricks-sdk": "*",
"@databricks/databricks-vscode-types": "workspace:^",
"@vscode/debugadapter": "^1.57.0",
"@vscode/webview-ui-toolkit": "^1.0.1"
},
Expand Down Expand Up @@ -505,4 +507,4 @@
],
"report-dir": "coverage"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,14 @@ export class ConnectionManager {
}
}

async waitForConnect() {
async waitForConnect(): Promise<void> {
if (this._state === "CONNECTED") {
return;
} else if (this._state === "CONNECTING") {
return await new Promise((resolve) => {
const changeListener = this.onDidChangeState(() => {
changeListener.dispose();
resolve(resolve);
resolve();
}, this);
});
}
Expand Down
7 changes: 6 additions & 1 deletion packages/databricks-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import {CodeSynchronizer} from "./sync/CodeSynchronizer";
import {BricksTaskProvider} from "./cli/BricksTasks";
import {ProjectConfigFileWatcher} from "./configuration/ProjectConfigFileWatcher";
import {QuickstartCommands} from "./quickstart/QuickstartCommands";
import {PublicApi} from "@databricks/databricks-vscode-types";

export function activate(context: ExtensionContext) {
export function activate(context: ExtensionContext): PublicApi {
let cli = new CliWrapper(context);
// Configuration group
let connectionManager = new ConnectionManager(cli);
Expand Down Expand Up @@ -199,6 +200,10 @@ export function activate(context: ExtensionContext) {
quickstartCommands
)
);

return {
connectionManager: connectionManager,
};
}

// this method is called when your extension is deactivated
Expand Down
Loading