| author | |
| committer | |
| log | 2431edfc4f3987c4c31909713ccf643d2253b02d |
| tree | 085f86df2473ea81ab23d46c35d83551cf78017e |
| parent | 9acda2123ed92a2b03d275c68e791311cb8d8bfd |
14 files changed, 49 insertions(+), 42 deletions(-)
docs/README.md+1-1| ... | ... | @@ -36,7 +36,7 @@ $ ./zig-out/bin/zigmod |
| 36 | 36 | |
| 37 | 37 | Check here for the [full command reference](./commands/). |
| 38 | 38 | |
| 39 | Check here for the [`zig.mod` reference](./zig.mod.md). | |
| 39 | Check here for the [`zigmod.yml` reference](./zig.mod.md). | |
| 40 | 40 | |
| 41 | 41 | Check here for the [`deps.zig` reference](./deps.zig.md). |
| 42 | 42 |
docs/commands/aq_add.md+2-2| ... | ... | @@ -3,8 +3,8 @@ |
| 3 | 3 | zigmod aq add <package> |
| 4 | 4 | ``` |
| 5 | 5 | |
| 6 | This command takes `<package>` and adds its most recent version to your `zig.mod`. | |
| 6 | This command takes `<package>` and adds its most recent version to your `zigmod.yml`. | |
| 7 | 7 | |
| 8 | 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 | 9 | |
| 10 | It will append the details to the end of your `zig.mod` 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. | |
| 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/ci.md+1-1| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | zigmod ci |
| 4 | 4 | ``` |
| 5 | 5 | |
| 6 | - This command takes no parameters and will do almost exactly the same thing as the [`fetch`](./fetch.md) command, except it will read version strings from your `zigmod.lock` file instead of from dependencies' `zig.mod` definitions. | |
| 6 | - This command takes no parameters and will do almost exactly the same thing as the [`fetch`](./fetch.md) command, except it will read version strings from your `zigmod.lock` file instead of from dependencies' `zigmod.yml` definitions. | |
| 7 | 7 | - Inspired by the [`npm ci`](https://docs.npmjs.com/cli/ci.html) command. |
| 8 | 8 | - Enables [Reproducible builds](https://reproducible-builds.org/). |
| 9 | 9 | - Often used in Continuous Integration environments. |
docs/commands/init.md+3-3| ... | ... | @@ -3,11 +3,11 @@ |
| 3 | 3 | zigmod init |
| 4 | 4 | ``` |
| 5 | 5 | |
| 6 | This command will help you generate a `zig.mod` file and place it in the current directory. This is the main file that will define various pieces of metadata about your project and manage your dependencies. The command will guide you though a number of questions that help you setup supporting files as well such as `.gitignore` and `LICENSE`. | |
| 6 | This command will help you generate a `zigmod.yml` file and place it in the current directory. This is the main file that will define various pieces of metadata about your project and manage your dependencies. The command will guide you though a number of questions that help you setup supporting files as well such as `.gitignore` and `LICENSE`. | |
| 7 | 7 | |
| 8 | Check out the [`zig.mod` reference](./../zig.mod.md) for more info. | |
| 8 | Check out the [`zigmod.yml` reference](./../zig.mod.md) for more info. | |
| 9 | 9 | |
| 10 | Also check out `zigmod`'s own `zig.mod` for a useful example: https://github.com/nektro/zigmod/blob/master/zig.mod. | |
| 10 | Also check out `zigmod`'s own `zigmod.yml` for a useful example: https://github.com/nektro/zigmod/blob/master/zig.mod. | |
| 11 | 11 | |
| 12 | 12 | ## Screenshot |
| 13 | 13 |  |
docs/commands/license_.md+5-4| ... | ... | @@ -3,9 +3,9 @@ |
| 3 | 3 | zigmod license |
| 4 | 4 | ``` |
| 5 | 5 | |
| 6 | This will print a listing of all of your dependencies (deeply)' licenses. Any code is valid for the `license` field in `zig.mod` but should it match a valid SPDX identifier, a URL to learn more about the license will also be printed so the user can learn more about it. | |
| 6 | This will print a listing of all of your dependencies (deeply)' licenses. Any code is valid for the `license` field in `zigmod.yml` but should it match a valid SPDX identifier, a URL to learn more about the license will also be printed so the user can learn more about it. | |
| 7 | 7 | |
| 8 | Should one of your dependencies not have a `license` field in their `zig.mod` manifest, an `Unspecified:` list will appear at the bottom of the output. | |
| 8 | Should one of your dependencies not have a `license` field in their `zigmod.yml` manifest, an `Unspecified:` list will appear at the bottom of the output. | |
| 9 | 9 | |
| 10 | 10 | Running this command on Zigmod itself (as of this writing) produces such output: |
| 11 | 11 | ``` |
| ... | ... | @@ -13,21 +13,22 @@ MIT: |
| 13 | 13 | = https://spdx.org/licenses/MIT |
| 14 | 14 | - This |
| 15 | 15 | - git https://github.com/yaml/libyaml |
| 16 | - git https://github.com/nektro/iguanaTLS | |
| 16 | 17 | - git https://github.com/nektro/zig-ansi |
| 17 | 18 | - git https://github.com/ziglibs/known-folders |
| 18 | 19 | - git https://github.com/nektro/zig-licenses |
| 19 | 20 | - git https://github.com/truemedian/zfetch |
| 20 | 21 | - git https://github.com/truemedian/hzzp |
| 21 | - git https://github.com/alexnask/iguanaTLS | |
| 22 | 22 | - git https://github.com/MasterQ32/zig-network |
| 23 | 23 | - git https://github.com/MasterQ32/zig-uri |
| 24 | 24 | - git https://github.com/nektro/zig-json |
| 25 | - git https://github.com/nektro/zig-extras | |
| 25 | 26 | - git https://github.com/nektro/zig-range |
| 26 | 27 | - git https://github.com/nektro/zig-detect-license |
| 27 | 28 | - git https://github.com/nektro/zig-licenses-text |
| 28 | 29 | - git https://github.com/nektro/zig-leven |
| 29 | - git https://github.com/nektro/zig-fs-check | |
| 30 | 30 | - git https://github.com/nektro/zig-inquirer |
| 31 | 31 | - git https://github.com/arqv/ini |
| 32 | - git https://github.com/nektro/zig-time | |
| 32 | 33 | - git https://github.com/marlersoft/zigwin32 |
| 33 | 34 | ``` |
docs/commands/zpm_add.md+3-3| ... | ... | @@ -3,10 +3,10 @@ |
| 3 | 3 | zigmod zpm add <name> |
| 4 | 4 | ``` |
| 5 | 5 | |
| 6 | - `<name>` is required and will pull the corresponding package from https://zpm.random-projects.net/ and add it to your `zig.mod`. | |
| 7 | - Since zpm is not native to Zigmod is will also manually define the `name` and `main` attributes based on the zpm data. Normally, if the source you reference contains a `zig.mod` file in its root, those fields are not required to defined by the dependent. | |
| 6 | - `<name>` is required and will pull the corresponding package from https://zpm.random-projects.net/ and add it to your `zigmod.yml`. | |
| 7 | - Since zpm is not native to Zigmod is will also manually define the `name` and `main` attributes based on the zpm data. Normally, if the source you reference contains a `zigmod.yml` file in its root, those fields are not required to defined by the dependent. | |
| 8 | 8 | |
| 9 | For example running `zigmod zpm add apple_pie` will append the following to your `zig.mod`: | |
| 9 | For example running `zigmod zpm add apple_pie` will append the following to your `zigmod.yml`: | |
| 10 | 10 | ```yml |
| 11 | 11 | - src: git https://github.com/Luukdegram/apple_pie |
| 12 | 12 | name: apple_pie |
docs/tutorial.md+3-3| ... | ... | @@ -11,7 +11,7 @@ zig init-exe |
| 11 | 11 | zigmod init |
| 12 | 12 | ``` |
| 13 | 13 | |
| 14 | Zigmod's init wizard will ask you if the current project is an application or a library and setup some initial properties in your `zig.mod`. However, if you do plan to have a project that is both a library to be used in other Zig projects and an application itself, don't fret. For Zigmod is able to support both of thses configurations simultaneously. | |
| 14 | Zigmod's init wizard will ask you if the current project is an application or a library and setup some initial properties in your `zigmod.yml`. However, if you do plan to have a project that is both a library to be used in other Zig projects and an application itself, don't fret. For Zigmod is able to support both of thses configurations simultaneously. | |
| 15 | 15 | |
| 16 | 16 | The wizard will also ask if you'd like it setup any additional metadata files such as `.gitignore` or `LICENSE` for you. |
| 17 | 17 | |
| ... | ... | @@ -19,7 +19,7 @@ The wizard will also ask if you'd like it setup any additional metadata files su |
| 19 | 19 | |
| 20 | 20 | --- |
| 21 | 21 | ## Running `zigmod fetch` |
| 22 | This command will inspect your `zig.mod` and download any new dependencies as well as pulling updates for any ones already download. It will recursively do this for your entire tree until it is full constructed which will culminate in the generation of two output files: `deps.zig` and `zigmod.lock`. | |
| 22 | This command will inspect your `zigmod.yml` and download any new dependencies as well as pulling updates for any ones already download. It will recursively do this for your entire tree until it is full constructed which will culminate in the generation of two output files: `deps.zig` and `zigmod.lock`. | |
| 23 | 23 | |
| 24 | 24 | `deps.zig` we will use in the next step integrating with the [Zig Build System](https://ziglang.org/documentation/master/#Zig-Build-System). [Learn more](./deps.zig.md). |
| 25 | 25 | |
| ... | ... | @@ -58,7 +58,7 @@ The core of expandability, it is possible to add dependencies to your project. H |
| 58 | 58 | - https://zig.pm/ is another supported pacakge index. You may add packages from ZPM with `zigmod zpm add <pacakge>`. |
| 59 | 59 | |
| 60 | 60 | - Other/Git |
| 61 | - Zigmod supports adding any Git repository as a dependency. This is done by manually editing your `zig.mod` and adding a line under either the `dependencies` or `dev_dependencies` keys. For example, adding a line with this contents would add `apple_pie` to your project: ` - src: git https://github.com/Luukdegram/apple_pie`. The URL field may be any valid Git url that you would pass to `git clone`. | |
| 61 | - Zigmod supports adding any Git repository as a dependency. This is done by manually editing your `zigmod.yml` and adding a line under either the `dependencies` or `dev_dependencies` keys. For example, adding a line with this contents would add `apple_pie` to your project: ` - src: git https://github.com/Luukdegram/apple_pie`. The URL field may be any valid Git url that you would pass to `git clone`. | |
| 62 | 62 | |
| 63 | 63 | - Other/System Library |
| 64 | 64 | - System libraries are similar to Git dependencies, but instead of `git <url>` it is `system_lib <name>`. |
docs/zig.mod.md+3-3| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | ## `zig.mod` Reference | |
| 1 | ## `zigmod.yml` Reference | |
| 2 | 2 | |
| 3 | `zig.mod` is the main manifest that Zigmod will read to learn all about your application or package. | |
| 3 | `zigmod.yml` is the main manifest that Zigmod will read to learn all about your application or package. | |
| 4 | 4 | |
| 5 | `zigmod.yml` is a valid alternative if needed. | |
| 5 | `zig.mod` is a valid legacy alternative. | |
| 6 | 6 | |
| 7 | 7 | ### `id` |
| 8 | 8 | - Type: `string` |
src/cmd/aquila/add.zig+1-4| ... | ... | @@ -36,10 +36,7 @@ pub fn do(dir: std.fs.Dir, pkg_id: string) !string { |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | const file = dir.openFile("zig.mod", .{ .mode = .read_write }) catch |err| switch (err) { | |
| 40 | error.FileNotFound => u.fail("error: zig.mod manifest not found! must run from project root.", .{}), | |
| 41 | else => return err, | |
| 42 | }; | |
| 39 | const file = try zigmod.ModFile.openFile(std.fs.cwd(), .{ .mode = .read_write }); | |
| 43 | 40 | defer file.close(); |
| 44 | 41 | try file.seekTo(try file.getEndPos()); |
| 45 | 42 |
src/cmd/aquila/install.zig+3-3| ... | ... | @@ -12,15 +12,15 @@ pub fn execute(args: [][]u8) !void { |
| 12 | 12 | const homepath = home.?; |
| 13 | 13 | const homedir = try std.fs.cwd().openDir(homepath, .{}); |
| 14 | 14 | |
| 15 | if (!(try u.does_file_exist(homedir, "zig.mod"))) { | |
| 16 | const f = try homedir.createFile("zig.mod", .{}); | |
| 15 | if (!(try u.does_file_exist(homedir, "zigmod.yml"))) { | |
| 16 | const f = try homedir.createFile("zigmod.yml", .{}); | |
| 17 | 17 | defer f.close(); |
| 18 | 18 | const w = f.writer(); |
| 19 | 19 | const init = @import("../init.zig"); |
| 20 | 20 | try init.writeExeManifest(w, try u.random_string(gpa, 48), "zigmod_installation", null, null); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | // add to ~/zig.mod for later | |
| 23 | // add to ~/zigmod.yml for later | |
| 24 | 24 | const aqadd = @import("./add.zig"); |
| 25 | 25 | const pkgurl = aqadd.do(homedir, args[0]) catch |err| switch (err) { |
| 26 | 26 | error.AquilaBadResponse => return, |
src/cmd/init.zig+3-6| ... | ... | @@ -15,7 +15,7 @@ const u = @import("./../util/index.zig"); |
| 15 | 15 | pub fn execute(args: [][]u8) !void { |
| 16 | 16 | _ = args; |
| 17 | 17 | |
| 18 | std.debug.print("This utility will walk you through creating a zig.mod file.\n", .{}); | |
| 18 | std.debug.print("This utility will walk you through creating a zigmod.yml file.\n", .{}); | |
| 19 | 19 | std.debug.print("That will give a good launching off point to get your next project started.\n", .{}); |
| 20 | 20 | std.debug.print("Use `zigmod aq add <pkg>` to add a dependency from https://aquila.red/\n", .{}); |
| 21 | 21 | std.debug.print("Press ^C at any time to quit.\n", .{}); |
| ... | ... | @@ -46,7 +46,7 @@ pub fn execute(args: [][]u8) !void { |
| 46 | 46 | const description = try inquirer.forString(stdout, stdin, "description:", gpa, null); |
| 47 | 47 | |
| 48 | 48 | std.debug.print("\n", .{}); |
| 49 | std.debug.print("About to write local zig.mod:\n", .{}); | |
| 49 | std.debug.print("About to write local zigmod.yml:\n", .{}); | |
| 50 | 50 | |
| 51 | 51 | std.debug.print("\n", .{}); |
| 52 | 52 | switch (ptype) { |
| ... | ... | @@ -61,7 +61,7 @@ pub fn execute(args: [][]u8) !void { |
| 61 | 61 | return; |
| 62 | 62 | }, |
| 63 | 63 | true => { |
| 64 | const file = try cwd.createFile("zig.mod", .{}); | |
| 64 | const file = try cwd.createFile("zigmod.yml", .{}); | |
| 65 | 65 | defer file.close(); |
| 66 | 66 | const w = file.writer(); |
| 67 | 67 | switch (ptype) { |
| ... | ... | @@ -166,10 +166,7 @@ pub fn execute(args: [][]u8) !void { |
| 166 | 166 | } |
| 167 | 167 | if (!exists) try w.writeAll("* text=auto\n"); |
| 168 | 168 | if (!exists) try w.writeAll("*.zig text eol=lf\n"); |
| 169 | try w.writeAll("zig.mod text eol=lf\n"); | |
| 170 | 169 | try w.writeAll("zigmod.* text eol=lf\n"); |
| 171 | try w.writeAll("zig.mod linguist-language=YAML\n"); | |
| 172 | try w.writeAll("zig.mod gitlab-language=yaml\n"); | |
| 173 | 170 | } |
| 174 | 171 | } |
| 175 | 172 | } |
src/cmd/zpm/add.zig+10-2| ... | ... | @@ -57,14 +57,22 @@ pub fn execute(args: [][]u8) !void { |
| 57 | 57 | try _req.do(.GET, null, null); |
| 58 | 58 | break :blk _req.status.code == 200; |
| 59 | 59 | }; |
| 60 | const has_zigmodyml = blk: { | |
| 61 | const _url = try std.mem.join(gpa, "/", &.{ found.git, "blob", "HEAD", "zigmod.yml" }); | |
| 62 | const _req = try zfetch.Request.init(gpa, _url, null); | |
| 63 | defer _req.deinit(); | |
| 64 | try _req.do(.GET, null, null); | |
| 65 | break :blk _req.status.code == 200; | |
| 66 | }; | |
| 60 | 67 | |
| 61 | const file = try std.fs.cwd().openFile("zig.mod", .{ .mode = .read_write }); | |
| 68 | const file = try zigmod.ModFile.openFile(std.fs.cwd(), .{ .mode = .read_write }); | |
| 69 | defer file.close(); | |
| 62 | 70 | try file.seekTo(try file.getEndPos()); |
| 63 | 71 | |
| 64 | 72 | const file_w = file.writer(); |
| 65 | 73 | try file_w.print("\n", .{}); |
| 66 | 74 | try file_w.print(" - src: git {s}\n", .{u.trim_suffix(found.git, ".git")}); |
| 67 | if (!has_zigdotmod) { | |
| 75 | if (!(has_zigdotmod or has_zigmodyml)) { | |
| 68 | 76 | try file_w.print(" name: {s}\n", .{found.name}); |
| 69 | 77 | try file_w.print(" main: {s}\n", .{found.root_file.?[1..]}); |
| 70 | 78 | } |
src/common.zig+1-1| ... | ... | @@ -268,7 +268,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO |
| 268 | 268 | if (mod_from.is_for_this()) return mod_from; |
| 269 | 269 | return null; |
| 270 | 270 | } |
| 271 | u.fail("no zig.mod found and no override props defined. unable to use add this dependency!", .{}); | |
| 271 | u.fail("no zig.mod or zigmod.yml found and no override props defined. unable to use add this dependency!", .{}); | |
| 272 | 272 | }, |
| 273 | 273 | else => e, |
| 274 | 274 | }; |
src/util/modfile.zig+10-6| ... | ... | @@ -30,18 +30,22 @@ pub const ModFile = struct { |
| 30 | 30 | min_zig_version: ?std.SemanticVersion, |
| 31 | 31 | vcpkg: bool, |
| 32 | 32 | |
| 33 | pub fn init(alloc: std.mem.Allocator) !Self { | |
| 34 | return try from_dir(alloc, std.fs.cwd()); | |
| 35 | } | |
| 36 | ||
| 37 | pub fn from_dir(alloc: std.mem.Allocator, dir: std.fs.Dir) !Self { | |
| 38 | const file = dir.openFile("zig.mod", .{}) catch |err| switch (err) { | |
| 33 | pub fn openFile(dir: std.fs.Dir, ops: std.fs.File.OpenFlags) !std.fs.File { | |
| 34 | return dir.openFile("zig.mod", ops) catch |err| switch (err) { | |
| 39 | 35 | error.FileNotFound => dir.openFile("zigmod.yml", .{}) catch |err2| switch (err2) { |
| 40 | 36 | error.FileNotFound => return error.ManifestNotFound, |
| 41 | 37 | else => |e2| return e2, |
| 42 | 38 | }, |
| 43 | 39 | else => |e| return e, |
| 44 | 40 | }; |
| 41 | } | |
| 42 | ||
| 43 | pub fn init(alloc: std.mem.Allocator) !Self { | |
| 44 | return try from_dir(alloc, std.fs.cwd()); | |
| 45 | } | |
| 46 | ||
| 47 | pub fn from_dir(alloc: std.mem.Allocator, dir: std.fs.Dir) !Self { | |
| 48 | const file = try openFile(dir, .{}); | |
| 45 | 49 | defer file.close(); |
| 46 | 50 | const input = try file.reader().readAllAlloc(alloc, mb); |
| 47 | 51 | const doc = try yaml.parse(alloc, input); |