authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-31 19:00:09 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-31 19:00:09 -07:00
log369e69f06c2d734d8b444ef50868b0cbe0bc4d5a
tree59a171970bfeec482b31330e5b4dc31af0e58ea6
parenta1aaef288bdd623356fb233ad518c233f49ce367

cmd/aq- remove modfile and update subcommdands, no longer used


6 files changed, 0 insertions(+), 119 deletions(-)

docs/commands/README.md-2
...@@ -15,6 +15,4 @@ Running `zigmod` with no commands will print this list....@@ -15,6 +15,4 @@ Running `zigmod` with no commands will print this list.
1515
16- [`aq`](aq.md)16- [`aq`](aq.md)
17- [`aq add`](aq_add.md)17- [`aq add`](aq_add.md)
18- [`aq update`](aq_update.md)
19- [`aq modfile`](aq_modfile.md)
20- [`aq showjson`](aq_showjson.md)18- [`aq showjson`](aq_showjson.md)
docs/commands/aq_modfile.md deleted-15
...@@ -1,15 +0,0 @@
1## `aq modfile` command
2```
3zigmod aq modfile <version>
4```
5
6This is a temporary command that can print the corresponding `zig.mod` yaml for a new version.
7
8If on the details page for a package version, the string `<version>` is expecting is the path of the url after the domain. So for the version https://aquila.red/1/nektro/iana-tlds/v0.2, the version ID is `1/nektro/iana-tlds/v0.2`.
9
10### Example Output
11`$ zigmod aq modfile 1/nektro/iana-tlds/v0.2`
12```
13 - src: http https://aquila.red/1/nektro/iana-tlds/v0.2.tar.gz _ 0 2
14 version: sha256-d2e50438ad3ab45ee56b13f285234bed0738c2cb7c1c7023da8489b48ecf876f
15```
docs/commands/aq_update.md deleted-8
...@@ -1,8 +0,0 @@
1## `aq update` command
2```
3zigmod aq update
4```
5
6This command takes no arguments and will check your `zig.mod` file for direct dependencies that have new versions available. If found it will print the respective version ID string that you can then pass to [`aq modfile`](aq_modfile.md) to get the relevant yaml text to update in your `zig.mod`.
7
8In the next version of the manifest format, this process will be done automatically without the need for `aq modfile`.
src/cmd/aq.zig-4
...@@ -11,8 +11,6 @@ const u = @import("./../util/index.zig");...@@ -11,8 +11,6 @@ const u = @import("./../util/index.zig");
1111
12pub const commands = struct {12pub const commands = struct {
13 pub const add = @import("./aquila/add.zig");13 pub const add = @import("./aquila/add.zig");
14 pub const update = @import("./aquila/update.zig");
15 pub const modfile = @import("./aquila/modfile.zig");
16 pub const showjson = @import("./aquila/showjson.zig");14 pub const showjson = @import("./aquila/showjson.zig");
17};15};
1816
...@@ -28,8 +26,6 @@ pub fn execute(args: [][]u8) !void {...@@ -28,8 +26,6 @@ pub fn execute(args: [][]u8) !void {
28 \\The subcommands available are:26 \\The subcommands available are:
29 \\ - add Append this package to your dependencies27 \\ - add Append this package to your dependencies
30 \\ - showjson Print debug api data to stdout28 \\ - showjson Print debug api data to stdout
31 \\ - update Check your zig.mod dependencies for new versions
32 \\ - modile Print the zig.mod text for a new version
33 });29 });
34 return;30 return;
35 }31 }
src/cmd/aquila/modfile.zig deleted-23
...@@ -1,23 +0,0 @@
1const std = @import("std");
2const gpa = std.heap.c_allocator;
3
4const u = @import("./../../util/index.zig");
5const aq = @import("./../aq.zig");
6
7//
8//
9
10pub fn execute(args: [][]u8) !void {
11 const pkg_id_v = args[0];
12
13 const url = try std.mem.join(gpa, "/", &.{ aq.server_root, pkg_id_v });
14 const val = try aq.server_fetch(url);
15
16 const v = val.get("vers").?;
17 const maj = v.get("real_major").?.Int;
18 const min = v.get("real_minor").?.Int;
19 const hash = v.get("tar_hash").?.String;
20
21 std.debug.print(" - src: http {s}/{s}.tar.gz _ {d} {d}\n", .{ aq.server_root, pkg_id_v, maj, min });
22 std.debug.print(" version: {s}\n", .{hash});
23}
src/cmd/aquila/update.zig deleted-67
...@@ -1,67 +0,0 @@
1const std = @import("std");
2const gpa = std.heap.c_allocator;
3
4const u = @import("./../../util/index.zig");
5const aq = @import("./../aq.zig");
6
7//
8//
9
10pub fn execute(args: [][]u8) !void {
11 _ = args;
12
13 const mod = try u.ModFile.init(gpa, "zig.mod");
14
15 for (mod.deps) |d| {
16 try check_dep(d);
17 }
18 for (mod.devdeps) |d| {
19 try check_dep(d);
20 }
21}
22
23fn check_dep(dep: u.Dep) !void {
24 if (dep.type != .http) {
25 return;
26 }
27 if (!std.mem.startsWith(u8, dep.path, aq.server_root)) {
28 return;
29 }
30 var pkg_id_v = std.mem.split(url_to_pkgid(dep.path), "/");
31 const host = pkg_id_v.next().?;
32 const user = pkg_id_v.next().?;
33 const pkg = pkg_id_v.next().?;
34 const vers = try vers_get_pieces(pkg_id_v.next().?);
35
36 const url = try std.mem.join(gpa, "/", &.{ aq.server_root, host, user, pkg });
37 const val = try aq.server_fetch(url);
38
39 const versions = val.get("versions").?.Array;
40 const latest = versions[versions.len - 1];
41
42 const rmaj = latest.get("real_major").?.Int;
43 const rmin = latest.get("real_minor").?.Int;
44
45 if (rmaj == vers[0] and rmin == vers[1]) {
46 return;
47 }
48
49 std.log.info("found new version: {s}/{s}/{s}/v{d}.{d}", .{ host, user, pkg, rmaj, rmin });
50}
51
52fn url_to_pkgid(url: []const u8) []const u8 {
53 var res = url;
54 res = u.trim_prefix(res, aq.server_root);
55 res = u.trim_suffix(res, ".tar.gz");
56 return res;
57}
58
59fn vers_get_pieces(v: []const u8) ![2]i64 {
60 var it = std.mem.split(v[1..], ".");
61 const maj = it.next().?;
62 const min = it.next().?;
63 return [_]i64{
64 try std.fmt.parseInt(i64, maj, 10),
65 try std.fmt.parseInt(i64, min, 10),
66 };
67}