diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 3acb409224c2226ce079389cb9e582f4d8e127fe..bd22c8a3f729e0b3ced7551a159288459c43c4a7 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -38,7 +38,6 @@ jobs: - run: zigmod sum - run: zigmod zpm add apple_pie - run: zigmod zpm tags - - run: zigmod aq add 1/vrischmann/sqlite - run: ./test_repo.sh https://github.com/nektro/zigmod-test-basic - run: ./test_repo.sh https://github.com/nektro/zigmod-test-git-dep diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index dc6b49400136f4e735df75bd10d68517b718eef7..f694dbbc7d37e91e8c57319d51d10b9417d13a25 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -50,7 +50,6 @@ jobs: - run: zigmod version - run: zigmod zpm add apple_pie - run: zigmod zpm tags - - run: zigmod aq add 1/vrischmann/sqlite - run: ./test_repo.sh https://github.com/nektro/zigmod-test-basic - run: ./test_repo.sh https://github.com/nektro/zigmod-test-git-dep diff --git a/README.md b/README.md index ac073f203d2387e92e271b782a957f9b60845410..6243c5bd4781147557fd8b87838bd58ec9140ffa 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,6 @@ Check out our [docs](docs/) or the website: https://nektro.github.io/zigmod/. There is now also a tutorial-style getting started guide that goes over various use cases that Zigmod provides and caters to. It is [available here](docs/tutorial.md). -A package index for Zigmod packages is also available at https://aquila.red/. - ## Contact - hello@nektro.net diff --git a/docs/commands/README.md b/docs/commands/README.md index 84e7caf15247f928fb2ad2b77e4e9fe21fe079ba..69cae5a2719896e5bf0861052a6cc7362818d90c 100644 --- a/docs/commands/README.md +++ b/docs/commands/README.md @@ -1,4 +1,5 @@ ## Commands + Listed below is all of the commands available in Zigmod. All are meant to be run in the build root of your project. Running `zigmod` with no commands will print this list. @@ -13,9 +14,3 @@ Running `zigmod` with no commands will print this list. - [`zpm`](zpm.md) - [`zpm add`](zpm_add.md) - [`zpm showjson`](zpm_showjson.md) - -- [`aq`](aq.md) -- [`aq add`](aq_add.md) -- [`aq showjson`](aq_showjson.md) -- [`aq install`](aq_install.md) -- [`aq update`](aq_update.md) diff --git a/docs/commands/aq.md b/docs/commands/aq.md deleted file mode 100644 index aa513934f180115c4ec8bf1b3567ba17afb2ed5a..0000000000000000000000000000000000000000 --- a/docs/commands/aq.md +++ /dev/null @@ -1,18 +0,0 @@ -## `aq` command -``` -zigmod aq -``` - -This is a stub subcommand for parenting all subcommands that interfact with instances of https://github.com/nektro/aquila and currently only displays help text. - -The default remote is https://aquila.red/. - -You can learn more about it on its wiki here: https://github.com/nektro/aquila/wiki. - -The subcommands available are: -- [`add`](aq_add.md) -- [`update`](aq_update.md) -- [`modfile`](aq_modfile.md) -- [`showjson`](aq_showjson.md) -- [`install`](aq_install.md) -- [`update`](aq_update.md) diff --git a/docs/commands/aq_add.md b/docs/commands/aq_add.md deleted file mode 100644 index a164fcee9df3c0947ec359c25e1249226dd3430b..0000000000000000000000000000000000000000 --- a/docs/commands/aq_add.md +++ /dev/null @@ -1,10 +0,0 @@ -## `aq add` command -``` -zigmod aq add -``` - -This command takes `` and adds its most recent version to your `zigmod.yml`. - -If you're on the details page for a package, the string this command is expecting is the path of the url after the domain name. So for example for the package https://aquila.red/1/truemedian/zfetch, you would add it using `zigmod aq add 1/truemedian/zfetch`. - -It will append the details to the end of your `zigmod.yml` file. If you're project is using both `dependencies` and `dev_dependencies` you may need to move the appended text up manually to the correct section. This step will be unnecessary in the next manifest format version. diff --git a/docs/commands/aq_install.md b/docs/commands/aq_install.md deleted file mode 100644 index b17e26d5dbdec6b300e9dbac339d2f8332018f7b..0000000000000000000000000000000000000000 --- a/docs/commands/aq_install.md +++ /dev/null @@ -1,12 +0,0 @@ -## `aq install` command -``` -zigmod aq install -``` - -This command takes `` and installs it for use on your local machine. - -If you're on the details page for a package, the string this command is expecting is the path of the url after the domain name. So for example for the package https://aquila.red/1/nektro/discord-archiver, you would add it using `zigmod aq install 1/nektro/discord-archiver`. - -Adding `~/.zigmod/bin` to your `$PATH` will allow you to reference the commands by name instead of by absolute path. - -The directory `~/.cache/zigmod` is a cache directory and may be deleted at any time. diff --git a/docs/commands/aq_showjson.md b/docs/commands/aq_showjson.md deleted file mode 100644 index 34091d0c76a9a18d60b31d0740704dc0e4fbe128..0000000000000000000000000000000000000000 --- a/docs/commands/aq_showjson.md +++ /dev/null @@ -1,20 +0,0 @@ -## `aq showjson` command -``` -zigmod aq showjson -``` - -This is a meta command for obtaining raw json from Aquila servers and ideally paired with [`jq`](https://stedolan.github.io/jq/). - -A number of extra functionality can be gained by composing this command with other utilities. Some examples are shown below: - ----- - -- List a user's published packages: -``` -zigmod aq showjson 1/nektro | jq '.pkgs[].name' -``` - -- List a package's published versions: -``` -zigmod aq showjson 1/nektro/iana-tlds | jq -c '.versions[] | [.real_major, .real_minor] | "v\(.[0]).\(.[1])"' -``` diff --git a/docs/commands/aq_update.md b/docs/commands/aq_update.md deleted file mode 100644 index ccb155206c7dd8bfa225d45f7a9cf5d6263822e6..0000000000000000000000000000000000000000 --- a/docs/commands/aq_update.md +++ /dev/null @@ -1,10 +0,0 @@ -## `aq update` command -``` -zigmod aq update -``` - -This command takes zero arguments and updates all programs installed with [`zigmod aq install`](./aq_install.md). - -Adding `~/.zigmod/bin` to your `$PATH` will allow you to reference the commands by name instead of by absolute path. - -The directory `~/.cache/zigmod` is a cache directory and may be deleted at any time. diff --git a/docs/tutorial.md b/docs/tutorial.md index 1675f2cbc434dd39b62abd165999eae11e897626..73e450ce8e4fa3b6d068869e8c048ce689f1ae2b 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -119,9 +119,6 @@ Alternatively, if you want to download updates exactly as defined by the lockfil ## Adding a dependency The core of expandability, it is possible to add dependencies to your project. How exactly, depends on where you're sourcing the information from. -- Aquila - - One place packages can be sourced from is https://aquila.red/. In order to add them to your project, you will obtain its ID in the form `1/truemedian/hzzp` and then run `zigmod aq add `. - - ZPM - https://zig.pm/ is another supported package index. You may add packages from ZPM with `zigmod zpm add `. @@ -178,20 +175,6 @@ Then push your local changes with `git push fork master` and create your pull re This will allow your Github Action task to use the various Zigmod commands. `zigmod ci` is recommended for this use case as it is similar to `zigmod fetch` but will fetch the versions only listed in your `zigmod.lock`. ---- -## Publishing your project on Aquila -https://github.com/nektro/aquila is a package index software and CI system designed to work in conjunction with Zigmod. - -> Note: I, @nektro, host a public instance at https://aquila.red/ available for anyone to use. However Aquila can be self hosted and the only difference in the following instructions will be the domain name. - -Navigating to https://aquila.red/ will show you the homepage with recent packages and most starred ones. - -Clicking the "Login" button will bring you to https://aquila.red/dashboard which will show you a list of your currently imported packages. The login screen will prompt you to authorize with an identity provider and ask you for webhook permissions. This is so that aquila can listen for new updates and automatically test them for the CI. - -The main nav will contain a link to https://aquila.red/import. Listed will be all of your not-imported Zig projects. Clicking "Select" will not immediately navigate the page in most browsers as the server will attempt to clone and verify your repository. Please be patient while it loads. - -Once it brings you to the package page it will now be available for discovery and be automatically included for testing. - --- ## Auditing your project's licenses This can come in handy for users and organizations alike. The `zigmod license` command will show you a list of the licenses involved in a project (deeply) and present them nicely grouping similar licenses together and providing a link to the license test for any projects that use a valid SPDX license identifier. @@ -211,4 +194,3 @@ Given the project https://github.com/kristoff-it/bork, at the time of writing th ## Installing online programs to your local machine Adding `~/.zigmod/bin` to your `$PATH` enables you to install Zig-written command line utilities to your machine with Zigmod. -> Ref: See [`zigmod aq install`](commands/aq_install.md) reference for more info. diff --git a/src/cmd/aq.zig b/src/cmd/aq.zig deleted file mode 100644 index bf11afea62f15895f9965b92751d9a22096586d7..0000000000000000000000000000000000000000 --- a/src/cmd/aq.zig +++ /dev/null @@ -1,66 +0,0 @@ -const std = @import("std"); -const string = []const u8; -const gpa = std.heap.c_allocator; -const zfetch = @import("zfetch"); -const extras = @import("extras"); -const json = @import("json"); - -const u = @import("./../util/funcs.zig"); - -// -// - -pub const commands = struct { - pub const add = @import("./aquila/add.zig"); - pub const showjson = @import("./aquila/showjson.zig"); - pub const install = @import("./aquila/install.zig"); - pub const update = @import("./aquila/update.zig"); -}; - -pub const server_root = "https://aquila.red"; - -pub fn execute(self_name: []const u8, args: [][:0]u8) !void { - if (args.len == 0) { - std.debug.print("{s}\n", .{ - \\This is a subcommand for use with https://github.com/nektro/aquila instances but has no default behavior on its own aside from showing you this nice help text. - \\ - \\The default remote is https://aquila.red. - \\ - \\The subcommands available are: - \\ - add Append this package to your dependencies - \\ - showjson Print debug api data to stdout - \\ - install Install a package - }); - return; - } - - inline for (comptime std.meta.declarations(commands)) |decl| { - if (std.mem.eql(u8, args[0], decl.name)) { - const cmd = @field(commands, decl.name); - try cmd.execute(self_name, args[1..]); - return; - } - } - u.fail("unknown command \"{s}\" for \"zigmod aq\"", .{args[0]}); -} - -pub fn server_fetch(url: string) !json.Document { - const req = try zfetch.Request.init(gpa, url, null); - defer req.deinit(); - - var headers = zfetch.Headers.init(gpa); - defer headers.deinit(); - try headers.set("accept", "application/json"); - - try req.do(.GET, headers, null); - - const doc = try json.parse(gpa, "", req.reader(), .{ .support_trailing_commas = true, .maximum_depth = 100 }); - doc.acquire(); - defer doc.release(); - - if (doc.root.object().getS("message")) |msg| { - std.log.err("server: {s}", .{msg}); - return error.AquilaBadResponse; - } - return doc; -} diff --git a/src/cmd/aquila/add.zig b/src/cmd/aquila/add.zig deleted file mode 100644 index 1f01e1af203a69a6363a0fe52867e84e899f3a33..0000000000000000000000000000000000000000 --- a/src/cmd/aquila/add.zig +++ /dev/null @@ -1,50 +0,0 @@ -const std = @import("std"); -const string = []const u8; -const gpa = std.heap.c_allocator; - -const zigmod = @import("../../lib.zig"); -const aq = @import("./../aq.zig"); - -// -// - -pub fn execute(self_name: []const u8, args: [][:0]u8) !void { - _ = self_name; - - const pkg_id = args[0]; - _ = try do(std.fs.cwd(), ".", pkg_id); - std.log.info("Successfully added package {s}", .{pkg_id}); -} - -pub fn do(dir: std.fs.Dir, dir_path: string, pkg_id: string) !string { - const url = try std.mem.join(gpa, "/", &.{ aq.server_root, pkg_id }); - const doc = try aq.server_fetch(url); - doc.acquire(); - defer doc.release(); - - const pkg_url = try std.fmt.allocPrint(gpa, "https://{s}/{s}", .{ - doc.root.object().getO("repo").?.getS("domain").?, - doc.root.object().getO("package").?.getS("remote_name").?, - }); - - const m = try zigmod.ModFile.from_dir(gpa, dir, dir_path); - for (m.rootdeps) |d| { - if (std.mem.eql(u8, d.path, pkg_url)) { - return pkg_url; - } - } - for (m.builddeps) |d| { - if (std.mem.eql(u8, d.path, pkg_url)) { - return pkg_url; - } - } - - _, var file = try zigmod.ModFile.openFile(dir, .{ .mode = .read_write }); - defer file.close(); - try file.seekTo(try file.getEndPos()); - - const file_w = file.writer(); - try file_w.print(" - src: git {s}\n", .{pkg_url}); - - return pkg_url; -} diff --git a/src/cmd/aquila/install.zig b/src/cmd/aquila/install.zig deleted file mode 100644 index 2b272672aafd10133f212f4730b68d9e07dfe8e2..0000000000000000000000000000000000000000 --- a/src/cmd/aquila/install.zig +++ /dev/null @@ -1,82 +0,0 @@ -const std = @import("std"); -const string = []const u8; -const gpa = std.heap.c_allocator; -const knownfolders = @import("known-folders"); -const extras = @import("extras"); - -const zigmod = @import("../../lib.zig"); -const u = @import("./../../util/funcs.zig"); -const common = @import("./../../common.zig"); - -pub fn execute(self_name: []const u8, args: [][:0]u8) !void { - _ = self_name; - - const home = try knownfolders.getPath(gpa, .home); - const homepath = home.?; - const homedir = try std.fs.cwd().openDir(homepath, .{}); - - if (!(try extras.doesFileExist(homedir, "zigmod.yml"))) { - const f = try homedir.createFile("zigmod.yml", .{}); - defer f.close(); - const w = f.writer(); - const init = @import("../init.zig"); - try init.writeExeManifest(w, &u.random_string(48), "zigmod_installation", null, null); - } - - // add to ~/zigmod.yml for later - const aqadd = @import("./add.zig"); - const pkgurl = aqadd.do(homedir, homepath, args[0]) catch |err| switch (err) { - error.AquilaBadResponse => return, - else => |ee| return ee, - }; - - // get modfile and dep - const m = try zigmod.ModFile.from_dir(gpa, homedir, homepath); - var dep: zigmod.Dep = undefined; - for (m.rootdeps) |d| { - if (std.mem.eql(u8, d.path, pkgurl)) { - dep = d; - break; - } - } - for (m.builddeps) |d| { - if (std.mem.eql(u8, d.path, pkgurl)) { - dep = d; - break; - } - } - - // - const cache = try knownfolders.getPath(gpa, .cache); - const cachepath = try std.fs.path.join(gpa, &.{ cache.?, "zigmod", "deps" }); - - // fetch singular pkg - var fetchoptions = common.CollectOptions{ - .log = true, - .update = false, - .alloc = gpa, - }; - try fetchoptions.init(); - const modpath = try common.get_modpath(cachepath, dep, &fetchoptions); - const moddir = try std.fs.cwd().openDir(modpath, .{}); - - // zigmod ci - const ci = @import("../ci.zig"); - try ci.do(gpa, cachepath, moddir); - - // zig build - const argv: []const string = &.{ - "zig", "build", - "--prefix", try std.fs.path.join(gpa, &.{ homepath, ".zigmod" }), - "--cache-dir", try std.fs.path.join(gpa, &.{ cache.?, "zigmod", "zig" }), - }; - var proc = std.process.Child.init(argv, gpa); - proc.cwd = modpath; - const term = try proc.spawnAndWait(); - switch (term) { - .Exited => |v| u.assert(v == 0, "zig build failed with exit code: {d}", .{v}), - .Signal => |v| std.log.info("zig build was stopped with signal: {d}", .{v}), - .Stopped => |v| std.log.info("zig build was stopped with code: {d}", .{v}), - .Unknown => |v| std.log.info("zig build encountered unknown: {d}", .{v}), - } -} diff --git a/src/cmd/aquila/showjson.zig b/src/cmd/aquila/showjson.zig deleted file mode 100644 index 8cc9fcc52cb288fe7bc95d430f7dfcd7838879ea..0000000000000000000000000000000000000000 --- a/src/cmd/aquila/showjson.zig +++ /dev/null @@ -1,20 +0,0 @@ -const std = @import("std"); -const gpa = std.heap.c_allocator; - -const aq = @import("./../aq.zig"); - -// -// - -pub fn execute(self_name: []const u8, args: [][:0]u8) !void { - _ = self_name; - - const out = std.io.getStdOut().writer(); - - const url = try std.mem.join(gpa, "/", &.{ aq.server_root, args[0] }); - const doc = try aq.server_fetch(url); - doc.acquire(); - defer doc.release(); - - try out.print("{}\n", .{doc}); -} diff --git a/src/cmd/aquila/update.zig b/src/cmd/aquila/update.zig deleted file mode 100644 index 80e2f830c223f5d51520c622db58470832a7453e..0000000000000000000000000000000000000000 --- a/src/cmd/aquila/update.zig +++ /dev/null @@ -1,69 +0,0 @@ -const std = @import("std"); -const string = []const u8; -const gpa = std.heap.c_allocator; -const knownfolders = @import("known-folders"); -const extras = @import("extras"); - -const zigmod = @import("../../lib.zig"); -const u = @import("./../../util/funcs.zig"); -const common = @import("./../../common.zig"); - -pub fn execute(self_name: []const u8, args: [][:0]u8) !void { - _ = self_name; - - const home = try knownfolders.getPath(gpa, .home); - const homepath = home.?; - const homedir = try std.fs.cwd().openDir(homepath, .{}); - - if (!(try extras.doesFileExist(homedir, "zigmod.yml"))) { - const f = try homedir.createFile("zigmod.yml", .{}); - defer f.close(); - const w = f.writer(); - const init = @import("../init.zig"); - try init.writeExeManifest(w, &u.random_string(48), "zigmod_installation", null, null); - } - u.assert(args.len == 0, "zigmod aq update accepts no parameters", .{}); - - // get modfile and dep - const m = try zigmod.ModFile.from_dir(gpa, homedir, homepath); - for (m.rootdeps) |dep| { - // - const cache = try knownfolders.getPath(gpa, .cache); - const cachepath = try std.fs.path.join(gpa, &.{ cache.?, "zigmod", "deps" }); - - // fetch singular pkg - var fetchoptions = common.CollectOptions{ - .log = true, - .update = false, - .alloc = gpa, - }; - try fetchoptions.init(); - const modpath = try common.get_modpath(cachepath, dep, &fetchoptions); - const moddir = try std.fs.cwd().openDir(modpath, .{}); - std.log.info("{s}", .{dep.path}); - - // git update - u.assert((try u.run_cmd(gpa, modpath, &.{ "git", "fetch" })) == 0, "git fetch failed", .{}); - u.assert((try u.run_cmd(gpa, modpath, &.{ "git", "pull" })) == 0, "git pull failed", .{}); - - // zigmod ci - const ci = @import("../ci.zig"); - try ci.do(gpa, cachepath, moddir); - - // zig build - const argv: []const string = &.{ - "zig", "build", - "--prefix", try std.fs.path.join(gpa, &.{ homepath, ".zigmod" }), - "--cache-dir", try std.fs.path.join(gpa, &.{ cache.?, "zigmod", "zig" }), - }; - var proc = std.process.Child.init(argv, gpa); - proc.cwd = modpath; - const term = try proc.spawnAndWait(); - switch (term) { - .Exited => |v| u.assert(v == 0, "zig build failed with exit code: {d}", .{v}), - .Signal => |v| std.log.info("zig build was interrupted with signal: {d}", .{v}), - .Stopped => |v| std.log.info("zig build was stopped with code: {d}", .{v}), - .Unknown => |v| std.log.info("zig build encountered unknown: {d}", .{v}), - } - } -} diff --git a/src/lib.zig b/src/lib.zig index 9fa01c32f4ff3fab5916ce1d7b247fa73e034328..241038e3baa31eb9f0153422c22f7b7cbb7b666c 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -12,7 +12,6 @@ pub const commands = struct { pub const sum = @import("./cmd/sum.zig"); pub const zpm = @import("./cmd/zpm.zig"); pub const license = @import("./cmd/license.zig"); - pub const aq = @import("./cmd/aq.zig"); pub const generate = @import("./cmd/generate.zig"); };