authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-03-06 16:02:58 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-03-06 16:02:58 -08:00
log2431edfc4f3987c4c31909713ccf643d2253b02d
tree085f86df2473ea81ab23d46c35d83551cf78017e
parent9acda2123ed92a2b03d275c68e791311cb8d8bfd

more zig.mod -> zigmod.yml renames


14 files changed, 49 insertions(+), 42 deletions(-)

docs/README.md+1-1
......@@ -36,7 +36,7 @@ $ ./zig-out/bin/zigmod
3636
3737Check here for the [full command reference](./commands/).
3838
39Check here for the [`zig.mod` reference](./zig.mod.md).
39Check here for the [`zigmod.yml` reference](./zig.mod.md).
4040
4141Check here for the [`deps.zig` reference](./deps.zig.md).
4242
docs/commands/aq_add.md+2-2
......@@ -3,8 +3,8 @@
33zigmod aq add <package>
44```
55
6This command takes `<package>` and adds its most recent version to your `zig.mod`.
6This command takes `<package>` and adds its most recent version to your `zigmod.yml`.
77
88If 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`.
99
10It 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.
10It 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 @@
33zigmod ci
44```
55
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.
77- Inspired by the [`npm ci`](https://docs.npmjs.com/cli/ci.html) command.
88- Enables [Reproducible builds](https://reproducible-builds.org/).
99- Often used in Continuous Integration environments.
docs/commands/init.md+3-3
......@@ -3,11 +3,11 @@
33zigmod init
44```
55
6This 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`.
6This 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`.
77
8Check out the [`zig.mod` reference](./../zig.mod.md) for more info.
8Check out the [`zigmod.yml` reference](./../zig.mod.md) for more info.
99
10Also check out `zigmod`'s own `zig.mod` for a useful example: https://github.com/nektro/zigmod/blob/master/zig.mod.
10Also check out `zigmod`'s own `zigmod.yml` for a useful example: https://github.com/nektro/zigmod/blob/master/zig.mod.
1111
1212## Screenshot
1313![image](https://user-images.githubusercontent.com/5464072/148404704-1082fd05-00fc-40ee-8cb7-17b538db3827.png)
docs/commands/license_.md+5-4
......@@ -3,9 +3,9 @@
33zigmod license
44```
55
6This 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.
6This 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.
77
8Should 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.
8Should 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.
99
1010Running this command on Zigmod itself (as of this writing) produces such output:
1111```
......@@ -13,21 +13,22 @@ MIT:
1313= https://spdx.org/licenses/MIT
1414- This
1515- git https://github.com/yaml/libyaml
16- git https://github.com/nektro/iguanaTLS
1617- git https://github.com/nektro/zig-ansi
1718- git https://github.com/ziglibs/known-folders
1819- git https://github.com/nektro/zig-licenses
1920- git https://github.com/truemedian/zfetch
2021- git https://github.com/truemedian/hzzp
21- git https://github.com/alexnask/iguanaTLS
2222- git https://github.com/MasterQ32/zig-network
2323- git https://github.com/MasterQ32/zig-uri
2424- git https://github.com/nektro/zig-json
25- git https://github.com/nektro/zig-extras
2526- git https://github.com/nektro/zig-range
2627- git https://github.com/nektro/zig-detect-license
2728- git https://github.com/nektro/zig-licenses-text
2829- git https://github.com/nektro/zig-leven
29- git https://github.com/nektro/zig-fs-check
3030- git https://github.com/nektro/zig-inquirer
3131- git https://github.com/arqv/ini
32- git https://github.com/nektro/zig-time
3233- git https://github.com/marlersoft/zigwin32
3334```
docs/commands/zpm_add.md+3-3
......@@ -3,10 +3,10 @@
33zigmod zpm add <name>
44```
55
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.
88
9For example running `zigmod zpm add apple_pie` will append the following to your `zig.mod`:
9For example running `zigmod zpm add apple_pie` will append the following to your `zigmod.yml`:
1010```yml
1111 - src: git https://github.com/Luukdegram/apple_pie
1212 name: apple_pie
docs/tutorial.md+3-3
......@@ -11,7 +11,7 @@ zig init-exe
1111zigmod init
1212```
1313
14Zigmod'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.
14Zigmod'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.
1515
1616The wizard will also ask if you'd like it setup any additional metadata files such as `.gitignore` or `LICENSE` for you.
1717
......@@ -19,7 +19,7 @@ The wizard will also ask if you'd like it setup any additional metadata files su
1919
2020---
2121## Running `zigmod fetch`
22This 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`.
22This 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`.
2323
2424`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).
2525
......@@ -58,7 +58,7 @@ The core of expandability, it is possible to add dependencies to your project. H
5858 - https://zig.pm/ is another supported pacakge index. You may add packages from ZPM with `zigmod zpm add <pacakge>`.
5959
6060- 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`.
6262
6363- Other/System Library
6464 - 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
22
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.
44
5`zigmod.yml` is a valid alternative if needed.
5`zig.mod` is a valid legacy alternative.
66
77### `id`
88- Type: `string`
src/cmd/aquila/add.zig+1-4
......@@ -36,10 +36,7 @@ pub fn do(dir: std.fs.Dir, pkg_id: string) !string {
3636 }
3737 }
3838
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 });
4340 defer file.close();
4441 try file.seekTo(try file.getEndPos());
4542
src/cmd/aquila/install.zig+3-3
......@@ -12,15 +12,15 @@ pub fn execute(args: [][]u8) !void {
1212 const homepath = home.?;
1313 const homedir = try std.fs.cwd().openDir(homepath, .{});
1414
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", .{});
1717 defer f.close();
1818 const w = f.writer();
1919 const init = @import("../init.zig");
2020 try init.writeExeManifest(w, try u.random_string(gpa, 48), "zigmod_installation", null, null);
2121 }
2222
23 // add to ~/zig.mod for later
23 // add to ~/zigmod.yml for later
2424 const aqadd = @import("./add.zig");
2525 const pkgurl = aqadd.do(homedir, args[0]) catch |err| switch (err) {
2626 error.AquilaBadResponse => return,
src/cmd/init.zig+3-6
......@@ -15,7 +15,7 @@ const u = @import("./../util/index.zig");
1515pub fn execute(args: [][]u8) !void {
1616 _ = args;
1717
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", .{});
1919 std.debug.print("That will give a good launching off point to get your next project started.\n", .{});
2020 std.debug.print("Use `zigmod aq add <pkg>` to add a dependency from https://aquila.red/\n", .{});
2121 std.debug.print("Press ^C at any time to quit.\n", .{});
......@@ -46,7 +46,7 @@ pub fn execute(args: [][]u8) !void {
4646 const description = try inquirer.forString(stdout, stdin, "description:", gpa, null);
4747
4848 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", .{});
5050
5151 std.debug.print("\n", .{});
5252 switch (ptype) {
......@@ -61,7 +61,7 @@ pub fn execute(args: [][]u8) !void {
6161 return;
6262 },
6363 true => {
64 const file = try cwd.createFile("zig.mod", .{});
64 const file = try cwd.createFile("zigmod.yml", .{});
6565 defer file.close();
6666 const w = file.writer();
6767 switch (ptype) {
......@@ -166,10 +166,7 @@ pub fn execute(args: [][]u8) !void {
166166 }
167167 if (!exists) try w.writeAll("* text=auto\n");
168168 if (!exists) try w.writeAll("*.zig text eol=lf\n");
169 try w.writeAll("zig.mod text eol=lf\n");
170169 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");
173170 }
174171 }
175172}
src/cmd/zpm/add.zig+10-2
......@@ -57,14 +57,22 @@ pub fn execute(args: [][]u8) !void {
5757 try _req.do(.GET, null, null);
5858 break :blk _req.status.code == 200;
5959 };
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 };
6067
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();
6270 try file.seekTo(try file.getEndPos());
6371
6472 const file_w = file.writer();
6573 try file_w.print("\n", .{});
6674 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)) {
6876 try file_w.print(" name: {s}\n", .{found.name});
6977 try file_w.print(" main: {s}\n", .{found.root_file.?[1..]});
7078 }
src/common.zig+1-1
......@@ -268,7 +268,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO
268268 if (mod_from.is_for_this()) return mod_from;
269269 return null;
270270 }
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!", .{});
272272 },
273273 else => e,
274274 };
src/util/modfile.zig+10-6
......@@ -30,18 +30,22 @@ pub const ModFile = struct {
3030 min_zig_version: ?std.SemanticVersion,
3131 vcpkg: bool,
3232
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) {
3935 error.FileNotFound => dir.openFile("zigmod.yml", .{}) catch |err2| switch (err2) {
4036 error.FileNotFound => return error.ManifestNotFound,
4137 else => |e2| return e2,
4238 },
4339 else => |e| return e,
4440 };
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, .{});
4549 defer file.close();
4650 const input = try file.reader().readAllAlloc(alloc, mb);
4751 const doc = try yaml.parse(alloc, input);