| 1 | const std = @import("std"); |
| 2 | const string = []const u8; |
| 3 | const nfs = @import("nfs"); |
| 4 | |
| 5 | const zigmod = @import("../lib.zig"); |
| 6 | const u = @import("./../util/funcs.zig"); |
| 7 | const common = @import("./../common.zig"); |
| 8 | |
| 9 | // Inspired by: |
| 10 | // https://docs.npmjs.com/cli/v7/commands/npm-ci |
| 11 | |
| 12 | pub fn execute(self_name: []const u8, args: []const [:0]const u8) !void { |
| 13 | _ = self_name; |
| 14 | _ = args; |
| 15 | |
| 16 | const gpa = std.heap.c_allocator; |
| 17 | const cachepath = try u.find_cachepath(); |
| 18 | const dir = nfs.cwd(); |
| 19 | try do(gpa, cachepath, dir); |
| 20 | } |
| 21 | |
| 22 | pub fn do(alloc: std.mem.Allocator, cachepath: [:0]const u8, dir: nfs.Dir) !void { |
| 23 | var options = common.CollectOptions{ |
| 24 | .log = true, |
| 25 | .update = false, |
| 26 | .lock = try common.parse_lockfile(alloc, dir), |
| 27 | .alloc = alloc, |
| 28 | }; |
| 29 | const top_module = try common.collect_deps_deep(cachepath, dir, &options); |
| 30 | |
| 31 | var list = std.array_list.Managed(zigmod.Module).init(alloc); |
| 32 | try common.collect_pkgs(top_module, &list); |
| 33 | |
| 34 | const fetch = @import("./fetch.zig"); |
| 35 | try fetch.create_depszig(alloc, cachepath, dir, top_module, &list); |
| 36 | } |