authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-24 02:46:21 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-24 02:46:21 -07:00
log01398787a634c479812373e27e8ffd14a0440afd
tree82ecfc9aec7bdd37cccb72cdfffb65ca5da0b1b9
parent4fb28757628afbfaba52cb48485130d6aace4063

cmd/aq/add- change to add source git dep instead of http dep


1 files changed, 4 insertions(+), 23 deletions(-)

src/cmd/aquila/add.zig+4-23
...@@ -13,33 +13,14 @@ pub fn execute(args: [][]u8) !void {...@@ -13,33 +13,14 @@ pub fn execute(args: [][]u8) !void {
13 const url = try std.mem.join(gpa, "/", &.{ aq.server_root, pkg_id });13 const url = try std.mem.join(gpa, "/", &.{ aq.server_root, pkg_id });
14 const val = try aq.server_fetch(url);14 const val = try aq.server_fetch(url);
1515
16 const name = val.get(.{ "pkg", "name" }).?.String;
17
18 const versions = val.get("versions").?.Array;
19 const to_add = versions[versions.len - 1];
20
21 const self_module = try u.ModFile.init(gpa, "zig.mod");
22 for (self_module.deps) |dep| {
23 if (std.mem.eql(u8, dep.name, name)) {
24 std.log.warn("dependency with name '{s}' already exists in your dependencies", .{name});
25 }
26 }
27 for (self_module.devdeps) |dep| {
28 if (std.mem.eql(u8, dep.name, name)) {
29 std.log.warn("dependency with name '{s}' already exists in your dependencies", .{name});
30 }
31 }
32
33 const file = try std.fs.cwd().openFile("zig.mod", .{ .read = true, .write = true });16 const file = try std.fs.cwd().openFile("zig.mod", .{ .read = true, .write = true });
34 try file.seekTo(try file.getEndPos());17 try file.seekTo(try file.getEndPos());
3518
36 const v_hash = to_add.get("tar_hash").?.String;
37 const v_maj = to_add.get("real_major").?.Int;
38 const v_min = to_add.get("real_minor").?.Int;
39
40 const file_w = file.writer();19 const file_w = file.writer();
41 try file_w.print("\n", .{});20 try file_w.print(" - src: git https://{s}/{s}\n", .{
42 try file_w.print(" - src: http {s}/v{d}.{d}.tar.gz {s} {d} {d}\n", .{ url, v_maj, v_min, v_hash[0..20], v_maj, v_min });21 val.get(.{ "repo", "domain" }).?.String,
22 val.get(.{ "pkg", "remote_name" }).?.String,
23 });
4324
44 std.log.info("Successfully added package {s}", .{pkg_id});25 std.log.info("Successfully added package {s}", .{pkg_id});
45}26}