Skip to content

Commit 98ad2f6

Browse files
Pull bricks CLI binary and add a test wrapper (#68)
* Package bricks cli with VSCode for darwin_arm64 * manual package action * manual package action * put package github action back * vscodeignore scripts * update fetch script * listen to process close * update task
1 parent 7ae869e commit 98ad2f6

File tree

8 files changed

+75
-1
lines changed

8 files changed

+75
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bin/**

packages/databricks-vscode/.vscode/tasks.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,32 @@
22
// for the documentation about the tasks.json format
33
{
44
"version": "2.0.0",
5+
"options": {
6+
"env": {
7+
"BRICKS_ARCH": "darwin_arm64"
8+
}
9+
},
510
"tasks": [
611
{
12+
"label": "Fetch bricks cli",
13+
"type": "shell",
14+
"command": "yarn",
15+
"args": ["run", "package:cli:fetch"]
16+
},
17+
{
18+
"label": "NPM watch",
719
"type": "npm",
820
"script": "watch",
921
"problemMatcher": "$tsc-watch",
1022
"isBackground": true,
1123
"presentation": {
1224
"reveal": "never",
1325
"group": "watchers"
14-
},
26+
}
27+
},
28+
{
29+
"label": "Build",
30+
"dependsOn": ["Fetch bricks cli", "NPM watch"],
1531
"group": {
1632
"kind": "build",
1733
"isDefault": true

packages/databricks-vscode/.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ src/**
99
**/.eslintrc.json
1010
**/*.map
1111
**/*.ts
12+
scripts/**

packages/databricks-vscode/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"onCommand:databricks.cli.startSync",
4949
"onCommand:databricks.cli.startSyncFull",
5050
"onCommand:databricks.cli.stopSync",
51+
"onCommand:databricks.cli.testBricksCli",
5152
"onCommand:databricks.cluster.refresh",
5253
"onCommand:databricks.cluster.filterByAll",
5354
"onCommand:databricks.cluster.filterByMe",
@@ -104,6 +105,10 @@
104105
"command": "databricks.cli.stopSync",
105106
"title": "Databricks: Stop synchronization"
106107
},
108+
{
109+
"command": "databricks.cli.testBricksCli",
110+
"title": "Databricks: test bricks cli"
111+
},
107112
{
108113
"command": "databricks.cluster.filterByAll",
109114
"title": "All"
@@ -267,6 +272,8 @@
267272
"scripts": {
268273
"vscode:prepublish": "rm -rf out && yarn run package:compile && yarn run package:copy-webview-toolkit",
269274
"package": "vsce package",
275+
"package:cli:fetch": "bash ./scripts/fetch-latest-bricks-cli.sh $BRICKS_ARCH",
276+
"package:cli:release": "bash ./scripts/fetch-latest-bricks-cli.sh $BRICKS_ARCH",
270277
"package:compile": "yarn run esbuild:base --minify",
271278
"package:copy-webview-toolkit": "cp ./node_modules/@vscode/webview-ui-toolkit/dist/toolkit.js ./out/toolkit.js",
272279
"esbuild:base": "esbuild ./src/extension.ts --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
BRICKS_ARCH=$1
2+
pushd /tmp
3+
rm -rf bricks_*
4+
gh release download -R databricks/bricks -p "*$BRICKS_ARCH.tar.gz"
5+
tar -xvf bricks_*_$BRICKS_ARCH.tar.gz
6+
7+
popd
8+
mkdir -p bin
9+
cd ./bin
10+
rm -rf bricks
11+
mv /tmp/bricks ./

packages/databricks-vscode/src/cli/CliCommands.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import {spawn} from "child_process";
12
import {
3+
ExtensionContext,
24
ProcessExecution,
35
Task,
46
TaskExecution,
@@ -19,6 +21,29 @@ export class CliCommands {
1921
private cli: CliWrapper
2022
) {}
2123

24+
testBricksCommand(context: ExtensionContext) {
25+
return () => {
26+
const {command, args} = this.cli.getTestBricksCommand(context);
27+
const cmd = spawn(command, args);
28+
29+
cmd.stdout.on("data", (data) => {
30+
console.log((data as Buffer).toString());
31+
});
32+
33+
cmd.on("exit", (code) => {
34+
if (code === 0) {
35+
console.log("Bricks cli found");
36+
} else {
37+
console.error("Bricks cli NOT found");
38+
}
39+
});
40+
41+
cmd.on("error", () => {
42+
console.error("Bricks cli NOT found");
43+
});
44+
};
45+
}
46+
2247
stopSyncCommand() {
2348
return () => {
2449
if (this.currentTaskExecution) {

packages/databricks-vscode/src/cli/CliWrapper.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {spawn} from "child_process";
2+
import {ExtensionContext} from "vscode";
23
import {SyncDestination} from "../configuration/SyncDestination";
34

45
interface Command {
@@ -15,6 +16,13 @@ interface Command {
1516
export class CliWrapper {
1617
constructor() {}
1718

19+
getTestBricksCommand(context: ExtensionContext): Command {
20+
return {
21+
command: context.asAbsolutePath("./bin/bricks"),
22+
args: [],
23+
};
24+
}
25+
1826
/**
1927
* Constructs the dbx sync command
2028
*/

packages/databricks-vscode/src/extension.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ export function activate(context: ExtensionContext) {
134134
"databricks.cli.stopSync",
135135
cliCommands.stopSyncCommand(),
136136
cliCommands
137+
),
138+
commands.registerCommand(
139+
"databricks.cli.testBricksCli",
140+
cliCommands.testBricksCommand(context),
141+
cliCommands
137142
)
138143
);
139144
}

0 commit comments

Comments
 (0)