authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-28 02:38:07 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-28 02:38:07 -07:00
log6fd42714e7ec2ab81732770c6eebc9ff7a683b5e
treeae73da38c86fbb8025f1ec7c93b25004f3add618
parente16a1f6d945521ff0cd81d6486dbbe86ae7c038f

move DepType to lib entry point


5 files changed, 11 insertions(+), 7 deletions(-)

src/common.zig+4-3
......@@ -5,6 +5,7 @@ const gpa = std.heap.c_allocator;
55
66const ansi = @import("ansi");
77
8const zigmod = @import("./lib.zig");
89const u = @import("./util/index.zig");
910const yaml = @import("./util/yaml.zig");
1011
......@@ -123,7 +124,7 @@ pub fn get_modpath(cachepath: string, d: u.Dep, options: *CollectOptions) !strin
123124 },
124125 .git => {
125126 if (d.version.len > 0) {
126 const vers = u.parse_split(u.DepType.GitVersion, "-").do(d.version) catch |e| switch (e) {
127 const vers = u.parse_split(zigmod.DepType.GitVersion, "-").do(d.version) catch |e| switch (e) {
127128 error.IterEmpty => unreachable,
128129 error.NoMemberFound => {
129130 const vtype = d.version[0..std.mem.indexOf(u8, d.version, "-").?];
......@@ -201,7 +202,7 @@ pub fn get_module_from_dep(d: *u.Dep, cachepath: string, options: *CollectOption
201202 if (options.lock) |lock| {
202203 for (lock) |item| {
203204 if (std.mem.eql(u8, item[0], try d.clean_path())) {
204 d.type = std.meta.stringToEnum(u.DepType, item[1]).?;
205 d.type = std.meta.stringToEnum(zigmod.DepType, item[1]).?;
205206 d.path = item[2];
206207 d.version = item[3];
207208 break;
......@@ -367,7 +368,7 @@ pub fn parse_lockfile(dir: std.fs.Dir) ![]const [4]string {
367368 2 => {
368369 var iter = std.mem.split(u8, line, " ");
369370 const asdep = u.Dep{
370 .type = std.meta.stringToEnum(u.DepType, iter.next().?).?,
371 .type = std.meta.stringToEnum(zigmod.DepType, iter.next().?).?,
371372 .path = iter.next().?,
372373 .version = iter.next().?,
373374 .id = "",
src/lib.zig+2
......@@ -22,3 +22,5 @@ pub fn init() !void {
2222pub fn deinit() void {
2323 zfetch.deinit();
2424}
25
26pub const DepType = @import("./util/dep_type.zig").DepType;
src/util/dep.zig+3-2
......@@ -3,6 +3,7 @@ const string = []const u8;
33const gpa = std.heap.c_allocator;
44const builtin = std.builtin;
55
6const zigmod = @import("../lib.zig");
67const u = @import("index.zig");
78const yaml = @import("./yaml.zig");
89
......@@ -12,7 +13,7 @@ const yaml = @import("./yaml.zig");
1213pub const Dep = struct {
1314 const Self = @This();
1415
15 type: u.DepType,
16 type: zigmod.DepType,
1617 path: string,
1718
1819 id: string,
......@@ -65,7 +66,7 @@ pub const Dep = struct {
6566 }
6667 return switch (self.type) {
6768 .git => blk: {
68 const vers = try u.parse_split(u.DepType.GitVersion, "-").do(self.version);
69 const vers = try u.parse_split(zigmod.DepType.GitVersion, "-").do(self.version);
6970 if (vers.id.frozen()) break :blk self.version;
7071 break :blk try self.type.exact_version(dpath);
7172 },
src/util/index.zig-1
......@@ -1,5 +1,4 @@
11usingnamespace @import("./funcs.zig");
2usingnamespace @import("./dep_type.zig");
32usingnamespace @import("./dep.zig");
43usingnamespace @import("./modfile.zig");
54usingnamespace @import("./module.zig");
src/util/modfile.zig+2-1
......@@ -1,6 +1,7 @@
11const std = @import("std");
22const string = []const u8;
33
4const zigmod = @import("../lib.zig");
45const u = @import("index.zig");
56const yaml = @import("./yaml.zig");
67
......@@ -94,7 +95,7 @@ pub const ModFile = struct {
9495 if (version == null) {
9596 version = "";
9697 }
97 const dep_type = std.meta.stringToEnum(u.DepType, dtype).?;
98 const dep_type = std.meta.stringToEnum(zigmod.DepType, dtype).?;
9899 if (dep_type == .local) {
99100 if (path.len > 0) {
100101 name = path;