diff --git a/docs/commands/README.md b/docs/commands/README.md index 2bba4abfda6887598a2cdd0bc668745efd9250b9..3611ec6f82bfef621d5ff8bd91f270e4bc5c7d66 100644 --- a/docs/commands/README.md +++ b/docs/commands/README.md @@ -15,6 +15,4 @@ Running `zigmod` with no commands will print this list. - [`aq`](aq.md) - [`aq add`](aq_add.md) -- [`aq update`](aq_update.md) -- [`aq modfile`](aq_modfile.md) - [`aq showjson`](aq_showjson.md) diff --git a/docs/commands/aq_modfile.md b/docs/commands/aq_modfile.md deleted file mode 100644 index 198c6d8defbb2438b37b139141d64b9a9a3c95fe..0000000000000000000000000000000000000000 --- a/docs/commands/aq_modfile.md +++ /dev/null @@ -1,15 +0,0 @@ -## `aq modfile` command -``` -zigmod aq modfile -``` - -This is a temporary command that can print the corresponding `zig.mod` yaml for a new version. - -If on the details page for a package version, the string `` 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`. - -### Example Output -`$ zigmod aq modfile 1/nektro/iana-tlds/v0.2` -``` - - src: http https://aquila.red/1/nektro/iana-tlds/v0.2.tar.gz _ 0 2 - version: sha256-d2e50438ad3ab45ee56b13f285234bed0738c2cb7c1c7023da8489b48ecf876f -``` diff --git a/docs/commands/aq_update.md b/docs/commands/aq_update.md deleted file mode 100644 index 466e13830383c5f909799ba8394c747087eaf614..0000000000000000000000000000000000000000 --- a/docs/commands/aq_update.md +++ /dev/null @@ -1,8 +0,0 @@ -## `aq update` command -``` -zigmod aq update -``` - -This 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`. - -In the next version of the manifest format, this process will be done automatically without the need for `aq modfile`. diff --git a/src/cmd/aq.zig b/src/cmd/aq.zig index 19fb6ec899e38ff254502a8653c7b368e75f0551..61bbedc48cafb22a243c6039b2873c228cd99020 100644 --- a/src/cmd/aq.zig +++ b/src/cmd/aq.zig @@ -11,8 +11,6 @@ const u = @import("./../util/index.zig"); pub const commands = struct { pub const add = @import("./aquila/add.zig"); - pub const update = @import("./aquila/update.zig"); - pub const modfile = @import("./aquila/modfile.zig"); pub const showjson = @import("./aquila/showjson.zig"); }; @@ -28,8 +26,6 @@ pub fn execute(args: [][]u8) !void { \\The subcommands available are: \\ - add Append this package to your dependencies \\ - showjson Print debug api data to stdout - \\ - update Check your zig.mod dependencies for new versions - \\ - modile Print the zig.mod text for a new version }); return; } diff --git a/src/cmd/aquila/modfile.zig b/src/cmd/aquila/modfile.zig deleted file mode 100644 index a4dfe0de574bddbc931bee5f0472655c088ac04a..0000000000000000000000000000000000000000 --- a/src/cmd/aquila/modfile.zig +++ /dev/null @@ -1,23 +0,0 @@ -const std = @import("std"); -const gpa = std.heap.c_allocator; - -const u = @import("./../../util/index.zig"); -const aq = @import("./../aq.zig"); - -// -// - -pub fn execute(args: [][]u8) !void { - const pkg_id_v = args[0]; - - const url = try std.mem.join(gpa, "/", &.{ aq.server_root, pkg_id_v }); - const val = try aq.server_fetch(url); - - const v = val.get("vers").?; - const maj = v.get("real_major").?.Int; - const min = v.get("real_minor").?.Int; - const hash = v.get("tar_hash").?.String; - - std.debug.print(" - src: http {s}/{s}.tar.gz _ {d} {d}\n", .{ aq.server_root, pkg_id_v, maj, min }); - std.debug.print(" version: {s}\n", .{hash}); -} diff --git a/src/cmd/aquila/update.zig b/src/cmd/aquila/update.zig deleted file mode 100644 index 409c3f784c2b3f49a85fec8446559b529c58a47a..0000000000000000000000000000000000000000 --- a/src/cmd/aquila/update.zig +++ /dev/null @@ -1,67 +0,0 @@ -const std = @import("std"); -const gpa = std.heap.c_allocator; - -const u = @import("./../../util/index.zig"); -const aq = @import("./../aq.zig"); - -// -// - -pub fn execute(args: [][]u8) !void { - _ = args; - - const mod = try u.ModFile.init(gpa, "zig.mod"); - - for (mod.deps) |d| { - try check_dep(d); - } - for (mod.devdeps) |d| { - try check_dep(d); - } -} - -fn check_dep(dep: u.Dep) !void { - if (dep.type != .http) { - return; - } - if (!std.mem.startsWith(u8, dep.path, aq.server_root)) { - return; - } - var pkg_id_v = std.mem.split(url_to_pkgid(dep.path), "/"); - const host = pkg_id_v.next().?; - const user = pkg_id_v.next().?; - const pkg = pkg_id_v.next().?; - const vers = try vers_get_pieces(pkg_id_v.next().?); - - const url = try std.mem.join(gpa, "/", &.{ aq.server_root, host, user, pkg }); - const val = try aq.server_fetch(url); - - const versions = val.get("versions").?.Array; - const latest = versions[versions.len - 1]; - - const rmaj = latest.get("real_major").?.Int; - const rmin = latest.get("real_minor").?.Int; - - if (rmaj == vers[0] and rmin == vers[1]) { - return; - } - - std.log.info("found new version: {s}/{s}/{s}/v{d}.{d}", .{ host, user, pkg, rmaj, rmin }); -} - -fn url_to_pkgid(url: []const u8) []const u8 { - var res = url; - res = u.trim_prefix(res, aq.server_root); - res = u.trim_suffix(res, ".tar.gz"); - return res; -} - -fn vers_get_pieces(v: []const u8) ![2]i64 { - var it = std.mem.split(v[1..], "."); - const maj = it.next().?; - const min = it.next().?; - return [_]i64{ - try std.fmt.parseInt(i64, maj, 10), - try std.fmt.parseInt(i64, min, 10), - }; -}