| 1 | ## `fetch` command |
| 2 | ``` |
| 3 | zigmod fetch |
| 4 | ``` |
| 5 | |
| 6 | - This command takes no parameters and will generate a `deps.zig` in the root of your project. This is the file that you will then import into your `build.zig` to automatically add all the necessary packages and (any) C code that may be in your dependencies. |
| 7 | - `deps.zig` is not typically checked into your source control. |
| 8 | - This command will also produce a `zigmod.lock` which you can use to easily generate [reproducible builds](https://reproducible-builds.org/) using the [`ci`](./ci.md) command. |
| 9 | |
| 10 | For a full reference on the fields available in `deps.zig` you can check [here](../deps.zig.md). |
| 11 | |
| 12 | ### Adding `deps.zig` to your `build.zig` |
| 13 | ```diff |
| 14 | const std = @import("std"); |
| 15 | +const deps = @import("./deps.zig"); |
| 16 | |
| 17 | pub fn build(b: *std.build.Builder) void { |
| 18 | const target = b.standardTargetOptions(.{}); |
| 19 | |
| 20 | const mode = b.standardReleaseOptions(); |
| 21 | |
| 22 | const exe = b.addExecutable("hello", "src/main.zig"); |
| 23 | exe.setTarget(target); |
| 24 | exe.setBuildMode(mode); |
| 25 | + deps.addAllTo(exe); |
| 26 | exe.install(); |
| 27 | ``` |
| 28 | |
| 29 | ## Screenshot |
| 30 |  |
| 31 | |
| 32 | In addition to fetching your dependencies `fetch` will help you track any updates. |
| 33 | |
| 34 | In the event you are using Git, `fetch` will parse the diff of your committed `zigmod.lock` with the new one it just printed and give you a status update on new packages, removed packages, or updated packages. If a dependency happens to be hosted on a major Git provider, then it will also reformat the updates section to print a compare URL so you may visit it in a browser and view the changes directly. Else, it will still print the "from" and "to" commits. |