| author | |
| committer | |
| log | 44c0c6c615900e9616e02514cc8b822afada9f0c |
| tree | 9bfd706cd35f48aac5a95d5d52dff4ab1db774d1 |
| parent | 9f80f414a25e5abce9993b6f88efb2d0ca1da751 |
3 files changed, 54 insertions(+), 20 deletions(-)
src/cmd/fetch.zig+2-1| ... | @@ -116,6 +116,7 @@ fn create_lockfile(list: *std.ArrayList(u.Module), dir: []const u8) !void { | ... | @@ -116,6 +116,7 @@ fn create_lockfile(list: *std.ArrayList(u.Module), dir: []const u8) !void { |
| 116 | defer fl.close(); | 116 | defer fl.close(); |
| 117 | 117 | ||
| 118 | const wl = fl.writer(); | 118 | const wl = fl.writer(); |
| 119 | try wl.writeAll("2\n"); | ||
| 119 | for (list.items) |m| { | 120 | for (list.items) |m| { |
| 120 | if (m.dep) |md| { | 121 | if (m.dep) |md| { |
| 121 | if (md.type == .local) { | 122 | if (md.type == .local) { |
| ... | @@ -123,7 +124,7 @@ fn create_lockfile(list: *std.ArrayList(u.Module), dir: []const u8) !void { | ... | @@ -123,7 +124,7 @@ fn create_lockfile(list: *std.ArrayList(u.Module), dir: []const u8) !void { |
| 123 | } | 124 | } |
| 124 | const mpath = try std.fs.path.join(gpa, &.{ dir, m.clean_path }); | 125 | const mpath = try std.fs.path.join(gpa, &.{ dir, m.clean_path }); |
| 125 | const version = if (md.version.len > 0) md.version else (try md.type.exact_version(mpath)); | 126 | const version = if (md.version.len > 0) md.version else (try md.type.exact_version(mpath)); |
| 126 | try wl.print("{s} {s} {s} {s}\n", .{ m.clean_path, @tagName(md.type), md.path, version }); | 127 | try wl.print("{s} {s} {s}\n", .{ @tagName(md.type), md.path, version }); |
| 127 | } | 128 | } |
| 128 | } | 129 | } |
| 129 | } | 130 | } |
src/common.zig+40-8| ... | @@ -296,14 +296,46 @@ pub fn parse_lockfile(path: []const u8) ![]const [4][]const u8 { | ... | @@ -296,14 +296,46 @@ pub fn parse_lockfile(path: []const u8) ![]const [4][]const u8 { |
| 296 | const max = std.math.maxInt(usize); | 296 | const max = std.math.maxInt(usize); |
| 297 | const f = try std.fs.cwd().openFile(path, .{}); | 297 | const f = try std.fs.cwd().openFile(path, .{}); |
| 298 | const r = f.reader(); | 298 | const r = f.reader(); |
| 299 | while (try r.readUntilDelimiterOrEofAlloc(gpa, '\n', max)) |line| { | 299 | var i: usize = 0; |
| 300 | var iter = std.mem.split(line, " "); | 300 | var v: usize = 1; |
| 301 | try list.append([4][]const u8{ | 301 | while (try r.readUntilDelimiterOrEofAlloc(gpa, '\n', max)) |line| : (i += 1) { |
| 302 | iter.next().?, | 302 | if (i == 0 and std.mem.eql(u8, line, "2")) { |
| 303 | iter.next().?, | 303 | v = 2; |
| 304 | iter.next().?, | 304 | continue; |
| 305 | iter.next().?, | 305 | } |
| 306 | }); | 306 | switch (v) { |
| 307 | 1 => { | ||
| 308 | var iter = std.mem.split(line, " "); | ||
| 309 | try list.append([4][]const u8{ | ||
| 310 | iter.next().?, | ||
| 311 | iter.next().?, | ||
| 312 | iter.next().?, | ||
| 313 | iter.next().?, | ||
| 314 | }); | ||
| 315 | }, | ||
| 316 | 2 => { | ||
| 317 | var iter = std.mem.split(line, " "); | ||
| 318 | const asdep = u.Dep{ | ||
| 319 | .type = std.meta.stringToEnum(u.DepType, iter.next().?).?, | ||
| 320 | .path = iter.next().?, | ||
| 321 | .version = iter.next().?, | ||
| 322 | .id = "", | ||
| 323 | .name = "", | ||
| 324 | .main = "", | ||
| 325 | .yaml = null, | ||
| 326 | .deps = &.{}, | ||
| 327 | }; | ||
| 328 | try list.append([4][]const u8{ | ||
| 329 | try asdep.clean_path(), | ||
| 330 | @tagName(asdep.type), | ||
| 331 | asdep.path, | ||
| 332 | asdep.version, | ||
| 333 | }); | ||
| 334 | }, | ||
| 335 | else => { | ||
| 336 | u.assert(false, "invalid zigmod.lock version: {d}", .{v}); | ||
| 337 | }, | ||
| 338 | } | ||
| 307 | } | 339 | } |
| 308 | return list.toOwnedSlice(); | 340 | return list.toOwnedSlice(); |
| 309 | } | 341 | } |
zigmod.lock+12-11| ... | @@ -1,11 +1,12 @@ | ... | @@ -1,11 +1,12 @@ |
| 1 | v/git/github.com/yaml/libyaml/tag-0.2.5 git https://github.com/yaml/libyaml tag-0.2.5 | 1 | 2 |
| 2 | git/github.com/nektro/zig-ansi git https://github.com/nektro/zig-ansi commit-930ab1f | 2 | git https://github.com/yaml/libyaml tag-0.2.5 |
| 3 | git/github.com/ziglibs/known-folders git https://github.com/ziglibs/known-folders commit-f5e5fb8 | 3 | git https://github.com/nektro/zig-ansi commit-930ab1f |
| 4 | git/github.com/nektro/zig-licenses git https://github.com/nektro/zig-licenses commit-499bee6 | 4 | git https://github.com/ziglibs/known-folders commit-f5e5fb8 |
| 5 | git/github.com/truemedian/zfetch git https://github.com/truemedian/zfetch commit-2cefe80 | 5 | git https://github.com/nektro/zig-licenses commit-499bee6 |
| 6 | git/github.com/truemedian/hzzp git https://github.com/truemedian/hzzp commit-2d30bdd | 6 | git https://github.com/truemedian/zfetch commit-2cefe80 |
| 7 | git/github.com/alexnask/iguanaTLS git https://github.com/alexnask/iguanaTLS commit-0d39a36 | 7 | git https://github.com/truemedian/hzzp commit-2d30bdd |
| 8 | git/github.com/MasterQ32/zig-network git https://github.com/MasterQ32/zig-network commit-b9c9176 | 8 | git https://github.com/alexnask/iguanaTLS commit-0d39a36 |
| 9 | git/github.com/MasterQ32/zig-uri git https://github.com/MasterQ32/zig-uri commit-f1896c6 | 9 | git https://github.com/MasterQ32/zig-network commit-b9c9176 |
| 10 | git/github.com/nektro/zig-json git https://github.com/nektro/zig-json commit-6599064 | 10 | git https://github.com/MasterQ32/zig-uri commit-f1896c6 |
| 11 | git/github.com/nektro/zig-range git https://github.com/nektro/zig-range commit-890ca30 | 11 | git https://github.com/nektro/zig-json commit-6599064 |
| 12 | git https://github.com/nektro/zig-range commit-890ca30 |