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...@@ -36,7 +36,7 @@ $ ./zig-out/bin/zigmod
3636
37Check here for the [full command reference](./commands/).37Check 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
41Check here for the [`deps.zig` reference](./deps.zig.md).41Check here for the [`deps.zig` reference](./deps.zig.md).
4242
docs/commands/aq_add.md+2-2
...@@ -3,8 +3,8 @@...@@ -3,8 +3,8 @@
3zigmod aq add <package>3zigmod aq add <package>
4```4```
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
8If 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`.8If 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 @@...@@ -3,7 +3,7 @@
3zigmod ci3zigmod ci
4```4```
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.
7- Inspired by the [`npm ci`](https://docs.npmjs.com/cli/ci.html) command.7- Inspired by the [`npm ci`](https://docs.npmjs.com/cli/ci.html) command.
8- Enables [Reproducible builds](https://reproducible-builds.org/).8- Enables [Reproducible builds](https://reproducible-builds.org/).
9- Often used in Continuous Integration environments.9- Often used in Continuous Integration environments.
docs/commands/init.md+3-3
...@@ -3,11 +3,11 @@...@@ -3,11 +3,11 @@
3zigmod init3zigmod init
4```4```
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
12## Screenshot12## Screenshot
13![image](https://user-images.githubusercontent.com/5464072/148404704-1082fd05-00fc-40ee-8cb7-17b538db3827.png)13![image](https://user-images.githubusercontent.com/5464072/148404704-1082fd05-00fc-40ee-8cb7-17b538db3827.png)
docs/commands/license_.md+5-4
...@@ -3,9 +3,9 @@...@@ -3,9 +3,9 @@
3zigmod license3zigmod license
4```4```
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
10Running this command on Zigmod itself (as of this writing) produces such output:10Running this command on Zigmod itself (as of this writing) produces such output:
11```11```
...@@ -13,21 +13,22 @@ MIT:...@@ -13,21 +13,22 @@ MIT:
13= https://spdx.org/licenses/MIT13= https://spdx.org/licenses/MIT
14- This14- This
15- git https://github.com/yaml/libyaml15- git https://github.com/yaml/libyaml
16- git https://github.com/nektro/iguanaTLS
16- git https://github.com/nektro/zig-ansi17- git https://github.com/nektro/zig-ansi
17- git https://github.com/ziglibs/known-folders18- git https://github.com/ziglibs/known-folders
18- git https://github.com/nektro/zig-licenses19- git https://github.com/nektro/zig-licenses
19- git https://github.com/truemedian/zfetch20- git https://github.com/truemedian/zfetch
20- git https://github.com/truemedian/hzzp21- git https://github.com/truemedian/hzzp
21- git https://github.com/alexnask/iguanaTLS
22- git https://github.com/MasterQ32/zig-network22- git https://github.com/MasterQ32/zig-network
23- git https://github.com/MasterQ32/zig-uri23- git https://github.com/MasterQ32/zig-uri
24- git https://github.com/nektro/zig-json24- git https://github.com/nektro/zig-json
25- git https://github.com/nektro/zig-extras
25- git https://github.com/nektro/zig-range26- git https://github.com/nektro/zig-range
26- git https://github.com/nektro/zig-detect-license27- git https://github.com/nektro/zig-detect-license
27- git https://github.com/nektro/zig-licenses-text28- git https://github.com/nektro/zig-licenses-text
28- git https://github.com/nektro/zig-leven29- git https://github.com/nektro/zig-leven
29- git https://github.com/nektro/zig-fs-check
30- git https://github.com/nektro/zig-inquirer30- git https://github.com/nektro/zig-inquirer
31- git https://github.com/arqv/ini31- git https://github.com/arqv/ini
32- git https://github.com/nektro/zig-time
32- git https://github.com/marlersoft/zigwin3233- git https://github.com/marlersoft/zigwin32
33```34```
docs/commands/zpm_add.md+3-3
...@@ -3,10 +3,10 @@...@@ -3,10 +3,10 @@
3zigmod zpm add <name>3zigmod zpm add <name>
4```4```
55
6- `<name>` is required and will pull the corresponding package from https://zpm.random-projects.net/ and add it to your `zig.mod`.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 `zig.mod` file in its root, those fields are not required to defined by the dependent.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`:
10```yml10```yml
11 - src: git https://github.com/Luukdegram/apple_pie11 - src: git https://github.com/Luukdegram/apple_pie
12 name: apple_pie12 name: apple_pie
docs/tutorial.md+3-3
...@@ -11,7 +11,7 @@ zig init-exe...@@ -11,7 +11,7 @@ zig init-exe
11zigmod init11zigmod init
12```12```
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
16The wizard will also ask if you'd like it setup any additional metadata files such as `.gitignore` or `LICENSE` for you.16The 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...@@ -19,7 +19,7 @@ The wizard will also ask if you'd like it setup any additional metadata files su
1919
20---20---
21## Running `zigmod fetch`21## 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
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).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).
2525
...@@ -58,7 +58,7 @@ The core of expandability, it is possible to add dependencies to your project. H...@@ -58,7 +58,7 @@ The core of expandability, it is possible to add dependencies to your project. H
58 - https://zig.pm/ is another supported pacakge index. You may add packages from ZPM with `zigmod zpm add <pacakge>`.58 - https://zig.pm/ is another supported pacakge index. You may add packages from ZPM with `zigmod zpm add <pacakge>`.
5959
60- Other/Git60- 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
63- Other/System Library63- Other/System Library
64 - System libraries are similar to Git dependencies, but instead of `git <url>` it is `system_lib <name>`.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,8 +1,8 @@
1## `zig.mod` Reference1## `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
7### `id`7### `id`
8- Type: `string`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,10 +36,7 @@ pub fn do(dir: std.fs.Dir, pkg_id: string) !string {
36 }36 }
37 }37 }
3838
39 const file = dir.openFile("zig.mod", .{ .mode = .read_write }) catch |err| switch (err) {39 const file = try zigmod.ModFile.openFile(std.fs.cwd(), .{ .mode = .read_write });
40 error.FileNotFound => u.fail("error: zig.mod manifest not found! must run from project root.", .{}),
41 else => return err,
42 };
43 defer file.close();40 defer file.close();
44 try file.seekTo(try file.getEndPos());41 try file.seekTo(try file.getEndPos());
4542
src/cmd/aquila/install.zig+3-3
...@@ -12,15 +12,15 @@ pub fn execute(args: [][]u8) !void {...@@ -12,15 +12,15 @@ pub fn execute(args: [][]u8) !void {
12 const homepath = home.?;12 const homepath = home.?;
13 const homedir = try std.fs.cwd().openDir(homepath, .{});13 const homedir = try std.fs.cwd().openDir(homepath, .{});
1414
15 if (!(try u.does_file_exist(homedir, "zig.mod"))) {15 if (!(try u.does_file_exist(homedir, "zigmod.yml"))) {
16 const f = try homedir.createFile("zig.mod", .{});16 const f = try homedir.createFile("zigmod.yml", .{});
17 defer f.close();17 defer f.close();
18 const w = f.writer();18 const w = f.writer();
19 const init = @import("../init.zig");19 const init = @import("../init.zig");
20 try init.writeExeManifest(w, try u.random_string(gpa, 48), "zigmod_installation", null, null);20 try init.writeExeManifest(w, try u.random_string(gpa, 48), "zigmod_installation", null, null);
21 }21 }
2222
23 // add to ~/zig.mod for later23 // add to ~/zigmod.yml for later
24 const aqadd = @import("./add.zig");24 const aqadd = @import("./add.zig");
25 const pkgurl = aqadd.do(homedir, args[0]) catch |err| switch (err) {25 const pkgurl = aqadd.do(homedir, args[0]) catch |err| switch (err) {
26 error.AquilaBadResponse => return,26 error.AquilaBadResponse => return,
src/cmd/init.zig+3-6
...@@ -15,7 +15,7 @@ const u = @import("./../util/index.zig");...@@ -15,7 +15,7 @@ const u = @import("./../util/index.zig");
15pub fn execute(args: [][]u8) !void {15pub fn execute(args: [][]u8) !void {
16 _ = args;16 _ = 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", .{});
19 std.debug.print("That will give a good launching off point to get your next project started.\n", .{});19 std.debug.print("That will give a good launching off point to get your next project started.\n", .{});
20 std.debug.print("Use `zigmod aq add <pkg>` to add a dependency from https://aquila.red/\n", .{});20 std.debug.print("Use `zigmod aq add <pkg>` to add a dependency from https://aquila.red/\n", .{});
21 std.debug.print("Press ^C at any time to quit.\n", .{});21 std.debug.print("Press ^C at any time to quit.\n", .{});
...@@ -46,7 +46,7 @@ pub fn execute(args: [][]u8) !void {...@@ -46,7 +46,7 @@ pub fn execute(args: [][]u8) !void {
46 const description = try inquirer.forString(stdout, stdin, "description:", gpa, null);46 const description = try inquirer.forString(stdout, stdin, "description:", gpa, null);
4747
48 std.debug.print("\n", .{});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", .{});
5050
51 std.debug.print("\n", .{});51 std.debug.print("\n", .{});
52 switch (ptype) {52 switch (ptype) {
...@@ -61,7 +61,7 @@ pub fn execute(args: [][]u8) !void {...@@ -61,7 +61,7 @@ pub fn execute(args: [][]u8) !void {
61 return;61 return;
62 },62 },
63 true => {63 true => {
64 const file = try cwd.createFile("zig.mod", .{});64 const file = try cwd.createFile("zigmod.yml", .{});
65 defer file.close();65 defer file.close();
66 const w = file.writer();66 const w = file.writer();
67 switch (ptype) {67 switch (ptype) {
...@@ -166,10 +166,7 @@ pub fn execute(args: [][]u8) !void {...@@ -166,10 +166,7 @@ pub fn execute(args: [][]u8) !void {
166 }166 }
167 if (!exists) try w.writeAll("* text=auto\n");167 if (!exists) try w.writeAll("* text=auto\n");
168 if (!exists) try w.writeAll("*.zig text eol=lf\n");168 if (!exists) try w.writeAll("*.zig text eol=lf\n");
169 try w.writeAll("zig.mod text eol=lf\n");
170 try w.writeAll("zigmod.* text eol=lf\n");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,14 +57,22 @@ pub fn execute(args: [][]u8) !void {
57 try _req.do(.GET, null, null);57 try _req.do(.GET, null, null);
58 break :blk _req.status.code == 200;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 };
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();
62 try file.seekTo(try file.getEndPos());70 try file.seekTo(try file.getEndPos());
6371
64 const file_w = file.writer();72 const file_w = file.writer();
65 try file_w.print("\n", .{});73 try file_w.print("\n", .{});
66 try file_w.print(" - src: git {s}\n", .{u.trim_suffix(found.git, ".git")});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 try file_w.print(" name: {s}\n", .{found.name});76 try file_w.print(" name: {s}\n", .{found.name});
69 try file_w.print(" main: {s}\n", .{found.root_file.?[1..]});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,7 +268,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO
268 if (mod_from.is_for_this()) return mod_from;268 if (mod_from.is_for_this()) return mod_from;
269 return null;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 else => e,273 else => e,
274 };274 };
src/util/modfile.zig+10-6
...@@ -30,18 +30,22 @@ pub const ModFile = struct {...@@ -30,18 +30,22 @@ pub const ModFile = struct {
30 min_zig_version: ?std.SemanticVersion,30 min_zig_version: ?std.SemanticVersion,
31 vcpkg: bool,31 vcpkg: bool,
3232
33 pub fn init(alloc: std.mem.Allocator) !Self {33 pub fn openFile(dir: std.fs.Dir, ops: std.fs.File.OpenFlags) !std.fs.File {
34 return try from_dir(alloc, std.fs.cwd());34 return dir.openFile("zig.mod", ops) catch |err| switch (err) {
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) {
39 error.FileNotFound => dir.openFile("zigmod.yml", .{}) catch |err2| switch (err2) {35 error.FileNotFound => dir.openFile("zigmod.yml", .{}) catch |err2| switch (err2) {
40 error.FileNotFound => return error.ManifestNotFound,36 error.FileNotFound => return error.ManifestNotFound,
41 else => |e2| return e2,37 else => |e2| return e2,
42 },38 },
43 else => |e| return e,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 defer file.close();49 defer file.close();
46 const input = try file.reader().readAllAlloc(alloc, mb);50 const input = try file.reader().readAllAlloc(alloc, mb);
47 const doc = try yaml.parse(alloc, input);51 const doc = try yaml.parse(alloc, input);