Skip to content

Commit 29d9d8c

Browse files
authored
Automatically install Coder CLI (#9)
* Run preflight before all binary invocations Otherwise the first command you run or action you perform will always fail, then the binary will install, then you have to redo the action. To accomplish this every command should call execCoder instead of calling exec directly. It did not appear necessary to have a separate exec and execCombined so I removed exec and renamed execCombined to exec. I also removed execJSON to avoid needing to have another function called execCoderJSON since you can just wrap with JSON.parse which is pretty minimal. Lastly I refactored the install logic so it includes a progress bar and can eventually support downloading the binary. * Stream installation progress Instead of waiting for the end. We will be able to use this for logs as well. * Make Coder CLI invocation an object This seems safer than trying to split on spaces. * Store extension context This will be needed to get the path for storing the binary. * Add code for making requests * Add code for extracting tars and zips * Download binary when not on PATH
1 parent 63a0bcf commit 29d9d8c

16 files changed

+1174
-131
lines changed

.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
coverage/**
55
out/**
66
src/**
7+
fixtures/**
78
.gitignore
89
node_modules/**
910
**/tsconfig.json

fixtures/archive.tar.gz

139 Bytes
Binary file not shown.

fixtures/archive.zip

196 Bytes
Binary file not shown.

fixtures/coder

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ need_login() {
77
exit 1
88
}
99

10+
fail() {
11+
echo fail
12+
exit 1
13+
}
14+
15+
success () {
16+
echo success
17+
exit 0
18+
}
19+
1020
workspaces() {
1121
cat ./workspaces.json
1222
exit 0
@@ -23,6 +33,8 @@ main() {
2333
# Mock the output based on the passed arguments.
2434
case "$*" in
2535
"envs ls --output json") workspaces ;;
36+
"test fail") fail ;;
37+
"test success") success ;;
2638
*) echo "$* is not mocked" ; exit 1 ;;
2739
esac
2840
}

0 commit comments

Comments
 (0)