Skip to content

Commit 5bb5398

Browse files
committed
chore: document steps for testing with local deps
1 parent c63a7ac commit 5bb5398

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

CONTRIBUTING.md

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ make build
4646
make build-debug
4747
```
4848

49-
Run the build binary like this.
49+
Then run `ls binary-releases` to confirm the name of the binary. For instance, if you are on an Apple Silicon Mac, run the CLI using:
5050

5151
```sh
52-
./binary-releases/snyk-macos --version
52+
./binary-releases/snyk-macos-arm64 --version
5353
```
5454

5555
## Debugging the go binary with VSCode
@@ -406,6 +406,58 @@ When upgrading golang, you will need to update the Dockerfile under .circleci, r
406406
GitHub, and update the docker executor that use the `snyklabs/cli-build-private` image in the .circleci/config.yml file, to use
407407
the new image.
408408

409+
## Building the CLI with local dependencies
410+
411+
You can build the CLI using local copies of either Go or TypeScript dependencies.
412+
413+
### Go
414+
415+
Add the following line (updated as required) to the bottom of `cliv2/go.mod`:
416+
417+
```go
418+
replace github.com/snyk/cli-extension-foo => ../../cli-extension-foo
419+
```
420+
421+
where `github.com/snyk/cli-extension-foo` is the name of the dependency and `../../cli-extension-foo` is your local copy of the repo, using a path relative to the `cliv2/go.mod` file.
422+
423+
Then run
424+
425+
```sh
426+
make build
427+
```
428+
429+
to build the CLI, and run it as usual with `./binary-releases/snyk-macos-arm64` (check the contents of `binary-releases/` to confirm the name of the binary, as this varies by platform).
430+
431+
### TypeScript
432+
433+
Find the line in `package.json` referencing the dependency you want to update, e.g. `"snyk-foo": "^1.2.3",` to point to your local copy of the dependency:
434+
435+
```json
436+
"snyk-foo": "file:../snyk-foo",
437+
```
438+
439+
assuming that you have the repo pulled down at `../snyk-foo` relative to the root of the CLI. Then, run:
440+
441+
```sh
442+
npm install
443+
```
444+
445+
to update your `package-lock.json`, and temporarily commit both changes:
446+
447+
```
448+
git add package*.json && git commit -m "temp"
449+
```
450+
451+
Be sure to drop that commit once you are done testing locally.
452+
453+
Then run:
454+
455+
```sh
456+
make clean && make build
457+
```
458+
459+
to build the ClI, and run it as usual with `./binary-releases/snyk-macos-arm64` (check the contents of `binary-releases/` to confirm the name of the binary, as this varies by platform).
460+
409461
---
410462

411463
Questions? Ask Team CLI 🔨

0 commit comments

Comments
 (0)