| author | |
| committer | |
| log | c0e9915f2340e6dd41e1ee0325b6ae3a843c66cf |
| tree | daa90d251e14ebfecea1ed373831b6cd073f7bc1 |
| parent | e3c15faf8be721eb39aeac741a97c814767ea79a |
| signature |
the site is still up but its not recommended to use anymore16 files changed, 1 insertions(+), 386 deletions(-)
.github/workflows/nightly.yml-1| ... | @@ -38,7 +38,6 @@ jobs: | ... | @@ -38,7 +38,6 @@ jobs: |
| 38 | - run: zigmod sum | 38 | - run: zigmod sum |
| 39 | - run: zigmod zpm add apple_pie | 39 | - run: zigmod zpm add apple_pie |
| 40 | - run: zigmod zpm tags | 40 | - run: zigmod zpm tags |
| 41 | - run: zigmod aq add 1/vrischmann/sqlite | ||
| 42 | 41 | ||
| 43 | - run: ./test_repo.sh https://github.com/nektro/zigmod-test-basic | 42 | - run: ./test_repo.sh https://github.com/nektro/zigmod-test-basic |
| 44 | - run: ./test_repo.sh https://github.com/nektro/zigmod-test-git-dep | 43 | - run: ./test_repo.sh https://github.com/nektro/zigmod-test-git-dep |
.github/workflows/push.yml-1| ... | @@ -50,7 +50,6 @@ jobs: | ... | @@ -50,7 +50,6 @@ jobs: |
| 50 | - run: zigmod version | 50 | - run: zigmod version |
| 51 | - run: zigmod zpm add apple_pie | 51 | - run: zigmod zpm add apple_pie |
| 52 | - run: zigmod zpm tags | 52 | - run: zigmod zpm tags |
| 53 | - run: zigmod aq add 1/vrischmann/sqlite | ||
| 54 | 53 | ||
| 55 | - run: ./test_repo.sh https://github.com/nektro/zigmod-test-basic | 54 | - run: ./test_repo.sh https://github.com/nektro/zigmod-test-basic |
| 56 | - run: ./test_repo.sh https://github.com/nektro/zigmod-test-git-dep | 55 | - run: ./test_repo.sh https://github.com/nektro/zigmod-test-git-dep |
README.md-2| ... | @@ -39,8 +39,6 @@ Check out our [docs](docs/) or the website: https://nektro.github.io/zigmod/. | ... | @@ -39,8 +39,6 @@ Check out our [docs](docs/) or the website: https://nektro.github.io/zigmod/. |
| 39 | 39 | ||
| 40 | 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). | 40 | 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). |
| 41 | 41 | ||
| 42 | A package index for Zigmod packages is also available at https://aquila.red/. | ||
| 43 | |||
| 44 | ## Contact | 42 | ## Contact |
| 45 | 43 | ||
| 46 | - hello@nektro.net | 44 | - hello@nektro.net |
docs/commands/README.md+1-6| ... | @@ -1,4 +1,5 @@ | ... | @@ -1,4 +1,5 @@ |
| 1 | ## Commands | 1 | ## Commands |
| 2 | |||
| 2 | Listed below is all of the commands available in Zigmod. All are meant to be run in the build root of your project. | 3 | Listed below is all of the commands available in Zigmod. All are meant to be run in the build root of your project. |
| 3 | 4 | ||
| 4 | Running `zigmod` with no commands will print this list. | 5 | Running `zigmod` with no commands will print this list. |
| ... | @@ -13,9 +14,3 @@ Running `zigmod` with no commands will print this list. | ... | @@ -13,9 +14,3 @@ Running `zigmod` with no commands will print this list. |
| 13 | - [`zpm`](zpm.md) | 14 | - [`zpm`](zpm.md) |
| 14 | - [`zpm add`](zpm_add.md) | 15 | - [`zpm add`](zpm_add.md) |
| 15 | - [`zpm showjson`](zpm_showjson.md) | 16 | - [`zpm showjson`](zpm_showjson.md) |
| 16 | |||
| 17 | - [`aq`](aq.md) | ||
| 18 | - [`aq add`](aq_add.md) | ||
| 19 | - [`aq showjson`](aq_showjson.md) | ||
| 20 | - [`aq install`](aq_install.md) | ||
| 21 | - [`aq update`](aq_update.md) |
docs/commands/aq.md deleted-18| ... | @@ -1,18 +0,0 @@ | ||
| 1 | ## `aq` command | ||
| 2 | ``` | ||
| 3 | zigmod aq | ||
| 4 | ``` | ||
| 5 | |||
| 6 | 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. | ||
| 7 | |||
| 8 | The default remote is https://aquila.red/. | ||
| 9 | |||
| 10 | You can learn more about it on its wiki here: https://github.com/nektro/aquila/wiki. | ||
| 11 | |||
| 12 | The subcommands available are: | ||
| 13 | - [`add`](aq_add.md) | ||
| 14 | - [`update`](aq_update.md) | ||
| 15 | - [`modfile`](aq_modfile.md) | ||
| 16 | - [`showjson`](aq_showjson.md) | ||
| 17 | - [`install`](aq_install.md) | ||
| 18 | - [`update`](aq_update.md) | ||
docs/commands/aq_add.md deleted-10| ... | @@ -1,10 +0,0 @@ | ||
| 1 | ## `aq add` command | ||
| 2 | ``` | ||
| 3 | zigmod aq add <package> | ||
| 4 | ``` | ||
| 5 | |||
| 6 | This command takes `<package>` and adds its most recent version to your `zigmod.yml`. | ||
| 7 | |||
| 8 | 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`. | ||
| 9 | |||
| 10 | 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. | ||
docs/commands/aq_install.md deleted-12| ... | @@ -1,12 +0,0 @@ | ||
| 1 | ## `aq install` command | ||
| 2 | ``` | ||
| 3 | zigmod aq install <package> | ||
| 4 | ``` | ||
| 5 | |||
| 6 | This command takes `<package>` and installs it for use on your local machine. | ||
| 7 | |||
| 8 | 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`. | ||
| 9 | |||
| 10 | Adding `~/.zigmod/bin` to your `$PATH` will allow you to reference the commands by name instead of by absolute path. | ||
| 11 | |||
| 12 | The directory `~/.cache/zigmod` is a cache directory and may be deleted at any time. | ||
docs/commands/aq_showjson.md deleted-20| ... | @@ -1,20 +0,0 @@ | ||
| 1 | ## `aq showjson` command | ||
| 2 | ``` | ||
| 3 | zigmod aq showjson <query> | ||
| 4 | ``` | ||
| 5 | |||
| 6 | This is a meta command for obtaining raw json from Aquila servers and ideally paired with [`jq`](https://stedolan.github.io/jq/). | ||
| 7 | |||
| 8 | A number of extra functionality can be gained by composing this command with other utilities. Some examples are shown below: | ||
| 9 | |||
| 10 | ---- | ||
| 11 | |||
| 12 | - List a user's published packages: | ||
| 13 | ``` | ||
| 14 | zigmod aq showjson 1/nektro | jq '.pkgs[].name' | ||
| 15 | ``` | ||
| 16 | |||
| 17 | - List a package's published versions: | ||
| 18 | ``` | ||
| 19 | zigmod aq showjson 1/nektro/iana-tlds | jq -c '.versions[] | [.real_major, .real_minor] | "v\(.[0]).\(.[1])"' | ||
| 20 | ``` | ||
docs/commands/aq_update.md deleted-10| ... | @@ -1,10 +0,0 @@ | ||
| 1 | ## `aq update` command | ||
| 2 | ``` | ||
| 3 | zigmod aq update | ||
| 4 | ``` | ||
| 5 | |||
| 6 | This command takes zero arguments and updates all programs installed with [`zigmod aq install`](./aq_install.md). | ||
| 7 | |||
| 8 | Adding `~/.zigmod/bin` to your `$PATH` will allow you to reference the commands by name instead of by absolute path. | ||
| 9 | |||
| 10 | The directory `~/.cache/zigmod` is a cache directory and may be deleted at any time. | ||
docs/tutorial.md-18| ... | @@ -119,9 +119,6 @@ Alternatively, if you want to download updates exactly as defined by the lockfil | ... | @@ -119,9 +119,6 @@ Alternatively, if you want to download updates exactly as defined by the lockfil |
| 119 | ## Adding a dependency | 119 | ## Adding a dependency |
| 120 | The core of expandability, it is possible to add dependencies to your project. How exactly, depends on where you're sourcing the information from. | 120 | The core of expandability, it is possible to add dependencies to your project. How exactly, depends on where you're sourcing the information from. |
| 121 | 121 | ||
| 122 | - Aquila | ||
| 123 | - 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 <package>`. | ||
| 124 | |||
| 125 | - ZPM | 122 | - ZPM |
| 126 | - https://zig.pm/ is another supported package index. You may add packages from ZPM with `zigmod zpm add <package>`. | 123 | - https://zig.pm/ is another supported package index. You may add packages from ZPM with `zigmod zpm add <package>`. |
| 127 | 124 | ||
| ... | @@ -178,20 +175,6 @@ Then push your local changes with `git push fork master` and create your pull re | ... | @@ -178,20 +175,6 @@ Then push your local changes with `git push fork master` and create your pull re |
| 178 | 175 | ||
| 179 | 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`. | 176 | 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`. |
| 180 | 177 | ||
| 181 | --- | ||
| 182 | ## Publishing your project on Aquila | ||
| 183 | https://github.com/nektro/aquila is a package index software and CI system designed to work in conjunction with Zigmod. | ||
| 184 | |||
| 185 | > 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. | ||
| 186 | |||
| 187 | Navigating to https://aquila.red/ will show you the homepage with recent packages and most starred ones. | ||
| 188 | |||
| 189 | 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. | ||
| 190 | |||
| 191 | 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. | ||
| 192 | |||
| 193 | Once it brings you to the package page it will now be available for discovery and be automatically included for testing. | ||
| 194 | |||
| 195 | --- | 178 | --- |
| 196 | ## Auditing your project's licenses | 179 | ## Auditing your project's licenses |
| 197 | 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. | 180 | 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 | ... | @@ -211,4 +194,3 @@ Given the project https://github.com/kristoff-it/bork, at the time of writing th |
| 211 | ## Installing online programs to your local machine | 194 | ## Installing online programs to your local machine |
| 212 | Adding `~/.zigmod/bin` to your `$PATH` enables you to install Zig-written command line utilities to your machine with Zigmod. | 195 | Adding `~/.zigmod/bin` to your `$PATH` enables you to install Zig-written command line utilities to your machine with Zigmod. |
| 213 | 196 | ||
| 214 | > Ref: See [`zigmod aq install`](commands/aq_install.md) reference for more info. |
src/cmd/aq.zig deleted-66| ... | @@ -1,66 +0,0 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const string = []const u8; | ||
| 3 | const gpa = std.heap.c_allocator; | ||
| 4 | const zfetch = @import("zfetch"); | ||
| 5 | const extras = @import("extras"); | ||
| 6 | const json = @import("json"); | ||
| 7 | |||
| 8 | const u = @import("./../util/funcs.zig"); | ||
| 9 | |||
| 10 | // | ||
| 11 | // | ||
| 12 | |||
| 13 | pub const commands = struct { | ||
| 14 | pub const add = @import("./aquila/add.zig"); | ||
| 15 | pub const showjson = @import("./aquila/showjson.zig"); | ||
| 16 | pub const install = @import("./aquila/install.zig"); | ||
| 17 | pub const update = @import("./aquila/update.zig"); | ||
| 18 | }; | ||
| 19 | |||
| 20 | pub const server_root = "https://aquila.red"; | ||
| 21 | |||
| 22 | pub fn execute(self_name: []const u8, args: [][:0]u8) !void { | ||
| 23 | if (args.len == 0) { | ||
| 24 | std.debug.print("{s}\n", .{ | ||
| 25 | \\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. | ||
| 26 | \\ | ||
| 27 | \\The default remote is https://aquila.red. | ||
| 28 | \\ | ||
| 29 | \\The subcommands available are: | ||
| 30 | \\ - add Append this package to your dependencies | ||
| 31 | \\ - showjson Print debug api data to stdout | ||
| 32 | \\ - install Install a package | ||
| 33 | }); | ||
| 34 | return; | ||
| 35 | } | ||
| 36 | |||
| 37 | inline for (comptime std.meta.declarations(commands)) |decl| { | ||
| 38 | if (std.mem.eql(u8, args[0], decl.name)) { | ||
| 39 | const cmd = @field(commands, decl.name); | ||
| 40 | try cmd.execute(self_name, args[1..]); | ||
| 41 | return; | ||
| 42 | } | ||
| 43 | } | ||
| 44 | u.fail("unknown command \"{s}\" for \"zigmod aq\"", .{args[0]}); | ||
| 45 | } | ||
| 46 | |||
| 47 | pub fn server_fetch(url: string) !json.Document { | ||
| 48 | const req = try zfetch.Request.init(gpa, url, null); | ||
| 49 | defer req.deinit(); | ||
| 50 | |||
| 51 | var headers = zfetch.Headers.init(gpa); | ||
| 52 | defer headers.deinit(); | ||
| 53 | try headers.set("accept", "application/json"); | ||
| 54 | |||
| 55 | try req.do(.GET, headers, null); | ||
| 56 | |||
| 57 | const doc = try json.parse(gpa, "", req.reader(), .{ .support_trailing_commas = true, .maximum_depth = 100 }); | ||
| 58 | doc.acquire(); | ||
| 59 | defer doc.release(); | ||
| 60 | |||
| 61 | if (doc.root.object().getS("message")) |msg| { | ||
| 62 | std.log.err("server: {s}", .{msg}); | ||
| 63 | return error.AquilaBadResponse; | ||
| 64 | } | ||
| 65 | return doc; | ||
| 66 | } | ||
src/cmd/aquila/add.zig deleted-50| ... | @@ -1,50 +0,0 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const string = []const u8; | ||
| 3 | const gpa = std.heap.c_allocator; | ||
| 4 | |||
| 5 | const zigmod = @import("../../lib.zig"); | ||
| 6 | const aq = @import("./../aq.zig"); | ||
| 7 | |||
| 8 | // | ||
| 9 | // | ||
| 10 | |||
| 11 | pub fn execute(self_name: []const u8, args: [][:0]u8) !void { | ||
| 12 | _ = self_name; | ||
| 13 | |||
| 14 | const pkg_id = args[0]; | ||
| 15 | _ = try do(std.fs.cwd(), ".", pkg_id); | ||
| 16 | std.log.info("Successfully added package {s}", .{pkg_id}); | ||
| 17 | } | ||
| 18 | |||
| 19 | pub fn do(dir: std.fs.Dir, dir_path: string, pkg_id: string) !string { | ||
| 20 | const url = try std.mem.join(gpa, "/", &.{ aq.server_root, pkg_id }); | ||
| 21 | const doc = try aq.server_fetch(url); | ||
| 22 | doc.acquire(); | ||
| 23 | defer doc.release(); | ||
| 24 | |||
| 25 | const pkg_url = try std.fmt.allocPrint(gpa, "https://{s}/{s}", .{ | ||
| 26 | doc.root.object().getO("repo").?.getS("domain").?, | ||
| 27 | doc.root.object().getO("package").?.getS("remote_name").?, | ||
| 28 | }); | ||
| 29 | |||
| 30 | const m = try zigmod.ModFile.from_dir(gpa, dir, dir_path); | ||
| 31 | for (m.rootdeps) |d| { | ||
| 32 | if (std.mem.eql(u8, d.path, pkg_url)) { | ||
| 33 | return pkg_url; | ||
| 34 | } | ||
| 35 | } | ||
| 36 | for (m.builddeps) |d| { | ||
| 37 | if (std.mem.eql(u8, d.path, pkg_url)) { | ||
| 38 | return pkg_url; | ||
| 39 | } | ||
| 40 | } | ||
| 41 | |||
| 42 | _, var file = try zigmod.ModFile.openFile(dir, .{ .mode = .read_write }); | ||
| 43 | defer file.close(); | ||
| 44 | try file.seekTo(try file.getEndPos()); | ||
| 45 | |||
| 46 | const file_w = file.writer(); | ||
| 47 | try file_w.print(" - src: git {s}\n", .{pkg_url}); | ||
| 48 | |||
| 49 | return pkg_url; | ||
| 50 | } | ||
src/cmd/aquila/install.zig deleted-82| ... | @@ -1,82 +0,0 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const string = []const u8; | ||
| 3 | const gpa = std.heap.c_allocator; | ||
| 4 | const knownfolders = @import("known-folders"); | ||
| 5 | const extras = @import("extras"); | ||
| 6 | |||
| 7 | const zigmod = @import("../../lib.zig"); | ||
| 8 | const u = @import("./../../util/funcs.zig"); | ||
| 9 | const common = @import("./../../common.zig"); | ||
| 10 | |||
| 11 | pub fn execute(self_name: []const u8, args: [][:0]u8) !void { | ||
| 12 | _ = self_name; | ||
| 13 | |||
| 14 | const home = try knownfolders.getPath(gpa, .home); | ||
| 15 | const homepath = home.?; | ||
| 16 | const homedir = try std.fs.cwd().openDir(homepath, .{}); | ||
| 17 | |||
| 18 | if (!(try extras.doesFileExist(homedir, "zigmod.yml"))) { | ||
| 19 | const f = try homedir.createFile("zigmod.yml", .{}); | ||
| 20 | defer f.close(); | ||
| 21 | const w = f.writer(); | ||
| 22 | const init = @import("../init.zig"); | ||
| 23 | try init.writeExeManifest(w, &u.random_string(48), "zigmod_installation", null, null); | ||
| 24 | } | ||
| 25 | |||
| 26 | // add to ~/zigmod.yml for later | ||
| 27 | const aqadd = @import("./add.zig"); | ||
| 28 | const pkgurl = aqadd.do(homedir, homepath, args[0]) catch |err| switch (err) { | ||
| 29 | error.AquilaBadResponse => return, | ||
| 30 | else => |ee| return ee, | ||
| 31 | }; | ||
| 32 | |||
| 33 | // get modfile and dep | ||
| 34 | const m = try zigmod.ModFile.from_dir(gpa, homedir, homepath); | ||
| 35 | var dep: zigmod.Dep = undefined; | ||
| 36 | for (m.rootdeps) |d| { | ||
| 37 | if (std.mem.eql(u8, d.path, pkgurl)) { | ||
| 38 | dep = d; | ||
| 39 | break; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | for (m.builddeps) |d| { | ||
| 43 | if (std.mem.eql(u8, d.path, pkgurl)) { | ||
| 44 | dep = d; | ||
| 45 | break; | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | // | ||
| 50 | const cache = try knownfolders.getPath(gpa, .cache); | ||
| 51 | const cachepath = try std.fs.path.join(gpa, &.{ cache.?, "zigmod", "deps" }); | ||
| 52 | |||
| 53 | // fetch singular pkg | ||
| 54 | var fetchoptions = common.CollectOptions{ | ||
| 55 | .log = true, | ||
| 56 | .update = false, | ||
| 57 | .alloc = gpa, | ||
| 58 | }; | ||
| 59 | try fetchoptions.init(); | ||
| 60 | const modpath = try common.get_modpath(cachepath, dep, &fetchoptions); | ||
| 61 | const moddir = try std.fs.cwd().openDir(modpath, .{}); | ||
| 62 | |||
| 63 | // zigmod ci | ||
| 64 | const ci = @import("../ci.zig"); | ||
| 65 | try ci.do(gpa, cachepath, moddir); | ||
| 66 | |||
| 67 | // zig build | ||
| 68 | const argv: []const string = &.{ | ||
| 69 | "zig", "build", | ||
| 70 | "--prefix", try std.fs.path.join(gpa, &.{ homepath, ".zigmod" }), | ||
| 71 | "--cache-dir", try std.fs.path.join(gpa, &.{ cache.?, "zigmod", "zig" }), | ||
| 72 | }; | ||
| 73 | var proc = std.process.Child.init(argv, gpa); | ||
| 74 | proc.cwd = modpath; | ||
| 75 | const term = try proc.spawnAndWait(); | ||
| 76 | switch (term) { | ||
| 77 | .Exited => |v| u.assert(v == 0, "zig build failed with exit code: {d}", .{v}), | ||
| 78 | .Signal => |v| std.log.info("zig build was stopped with signal: {d}", .{v}), | ||
| 79 | .Stopped => |v| std.log.info("zig build was stopped with code: {d}", .{v}), | ||
| 80 | .Unknown => |v| std.log.info("zig build encountered unknown: {d}", .{v}), | ||
| 81 | } | ||
| 82 | } | ||
src/cmd/aquila/showjson.zig deleted-20| ... | @@ -1,20 +0,0 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const gpa = std.heap.c_allocator; | ||
| 3 | |||
| 4 | const aq = @import("./../aq.zig"); | ||
| 5 | |||
| 6 | // | ||
| 7 | // | ||
| 8 | |||
| 9 | pub fn execute(self_name: []const u8, args: [][:0]u8) !void { | ||
| 10 | _ = self_name; | ||
| 11 | |||
| 12 | const out = std.io.getStdOut().writer(); | ||
| 13 | |||
| 14 | const url = try std.mem.join(gpa, "/", &.{ aq.server_root, args[0] }); | ||
| 15 | const doc = try aq.server_fetch(url); | ||
| 16 | doc.acquire(); | ||
| 17 | defer doc.release(); | ||
| 18 | |||
| 19 | try out.print("{}\n", .{doc}); | ||
| 20 | } | ||
src/cmd/aquila/update.zig deleted-69| ... | @@ -1,69 +0,0 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const string = []const u8; | ||
| 3 | const gpa = std.heap.c_allocator; | ||
| 4 | const knownfolders = @import("known-folders"); | ||
| 5 | const extras = @import("extras"); | ||
| 6 | |||
| 7 | const zigmod = @import("../../lib.zig"); | ||
| 8 | const u = @import("./../../util/funcs.zig"); | ||
| 9 | const common = @import("./../../common.zig"); | ||
| 10 | |||
| 11 | pub fn execute(self_name: []const u8, args: [][:0]u8) !void { | ||
| 12 | _ = self_name; | ||
| 13 | |||
| 14 | const home = try knownfolders.getPath(gpa, .home); | ||
| 15 | const homepath = home.?; | ||
| 16 | const homedir = try std.fs.cwd().openDir(homepath, .{}); | ||
| 17 | |||
| 18 | if (!(try extras.doesFileExist(homedir, "zigmod.yml"))) { | ||
| 19 | const f = try homedir.createFile("zigmod.yml", .{}); | ||
| 20 | defer f.close(); | ||
| 21 | const w = f.writer(); | ||
| 22 | const init = @import("../init.zig"); | ||
| 23 | try init.writeExeManifest(w, &u.random_string(48), "zigmod_installation", null, null); | ||
| 24 | } | ||
| 25 | u.assert(args.len == 0, "zigmod aq update accepts no parameters", .{}); | ||
| 26 | |||
| 27 | // get modfile and dep | ||
| 28 | const m = try zigmod.ModFile.from_dir(gpa, homedir, homepath); | ||
| 29 | for (m.rootdeps) |dep| { | ||
| 30 | // | ||
| 31 | const cache = try knownfolders.getPath(gpa, .cache); | ||
| 32 | const cachepath = try std.fs.path.join(gpa, &.{ cache.?, "zigmod", "deps" }); | ||
| 33 | |||
| 34 | // fetch singular pkg | ||
| 35 | var fetchoptions = common.CollectOptions{ | ||
| 36 | .log = true, | ||
| 37 | .update = false, | ||
| 38 | .alloc = gpa, | ||
| 39 | }; | ||
| 40 | try fetchoptions.init(); | ||
| 41 | const modpath = try common.get_modpath(cachepath, dep, &fetchoptions); | ||
| 42 | const moddir = try std.fs.cwd().openDir(modpath, .{}); | ||
| 43 | std.log.info("{s}", .{dep.path}); | ||
| 44 | |||
| 45 | // git update | ||
| 46 | u.assert((try u.run_cmd(gpa, modpath, &.{ "git", "fetch" })) == 0, "git fetch failed", .{}); | ||
| 47 | u.assert((try u.run_cmd(gpa, modpath, &.{ "git", "pull" })) == 0, "git pull failed", .{}); | ||
| 48 | |||
| 49 | // zigmod ci | ||
| 50 | const ci = @import("../ci.zig"); | ||
| 51 | try ci.do(gpa, cachepath, moddir); | ||
| 52 | |||
| 53 | // zig build | ||
| 54 | const argv: []const string = &.{ | ||
| 55 | "zig", "build", | ||
| 56 | "--prefix", try std.fs.path.join(gpa, &.{ homepath, ".zigmod" }), | ||
| 57 | "--cache-dir", try std.fs.path.join(gpa, &.{ cache.?, "zigmod", "zig" }), | ||
| 58 | }; | ||
| 59 | var proc = std.process.Child.init(argv, gpa); | ||
| 60 | proc.cwd = modpath; | ||
| 61 | const term = try proc.spawnAndWait(); | ||
| 62 | switch (term) { | ||
| 63 | .Exited => |v| u.assert(v == 0, "zig build failed with exit code: {d}", .{v}), | ||
| 64 | .Signal => |v| std.log.info("zig build was interrupted with signal: {d}", .{v}), | ||
| 65 | .Stopped => |v| std.log.info("zig build was stopped with code: {d}", .{v}), | ||
| 66 | .Unknown => |v| std.log.info("zig build encountered unknown: {d}", .{v}), | ||
| 67 | } | ||
| 68 | } | ||
| 69 | } | ||
src/lib.zig-1| ... | @@ -12,7 +12,6 @@ pub const commands = struct { | ... | @@ -12,7 +12,6 @@ pub const commands = struct { |
| 12 | pub const sum = @import("./cmd/sum.zig"); | 12 | pub const sum = @import("./cmd/sum.zig"); |
| 13 | pub const zpm = @import("./cmd/zpm.zig"); | 13 | pub const zpm = @import("./cmd/zpm.zig"); |
| 14 | pub const license = @import("./cmd/license.zig"); | 14 | pub const license = @import("./cmd/license.zig"); |
| 15 | pub const aq = @import("./cmd/aq.zig"); | ||
| 16 | pub const generate = @import("./cmd/generate.zig"); | 15 | pub const generate = @import("./cmd/generate.zig"); |
| 17 | }; | 16 | }; |
| 18 | 17 |