| 1 | const std = @import("std"); |
| 2 | const gpa = std.heap.c_allocator; |
| 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 | // |
| 10 | // |
| 11 | |
| 12 | pub fn execute(self_name: []const u8, args: []const [:0]const u8) !void { |
| 13 | _ = self_name; |
| 14 | _ = args; |
| 15 | |
| 16 | const cachepath = try u.find_cachepath(); |
| 17 | const dir = nfs.cwd(); |
| 18 | |
| 19 | var options = common.CollectOptions{ |
| 20 | .log = false, |
| 21 | .update = false, |
| 22 | .alloc = gpa, |
| 23 | }; |
| 24 | const top_module = try common.collect_deps_deep(cachepath, dir, &options); |
| 25 | |
| 26 | // |
| 27 | const f = try dir.createFile("zigmod.sum", .{}); |
| 28 | defer f.close(); |
| 29 | const w = f; |
| 30 | |
| 31 | // |
| 32 | var module_list = std.array_list.Managed(zigmod.Module).init(gpa); |
| 33 | try common.collect_pkgs(top_module, &module_list); |
| 34 | |
| 35 | for (module_list.items) |m| { |
| 36 | if (m.clean_path.len == 0) { |
| 37 | continue; |
| 38 | } |
| 39 | if (std.mem.eql(u8, m.clean_path, "../..")) { |
| 40 | continue; |
| 41 | } |
| 42 | if (m.type.isLocal()) continue; |
| 43 | const hash = try m.get_hash(gpa, cachepath); |
| 44 | try w.print("{s} {s}\n", .{ hash, m.clean_path }); |
| 45 | } |
| 46 | } |