| author | |
| committer | |
| log | 26b16273bda24a08741ddc60a9be0a62473dd653 |
| tree | 66539182e81dc36722a831cf6a8a86b427aca1b1 |
| parent | 25a046c27248b925e38c8ef4e2dd62c9d96f0ded |
11 files changed, 80 insertions(+), 58 deletions(-)
deps.zig+15-1| ... | ... | @@ -63,6 +63,8 @@ pub fn fetch(exe: *std.Build.Step.Compile) *std.Build.Step { |
| 63 | 63 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-extras", "74f0ddb0a4dfa7921739b88cc381951a6b6e73ce").step); |
| 64 | 64 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-git", "103f4e419c35b88f802bb8234ece1c0a9aa40c03").step); |
| 65 | 65 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-inquirer", "cf43dd6c9f328073f7468b5341c69ed0bb185db3").step); |
| 66 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-intrusive-parser", "2336d8b767eb7378762e1ba63635ca44accbd2ca").step); | |
| 67 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-json", "29587071de6dd3338e8eb76d4e0307af69a2d61a").step); | |
| 66 | 68 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-leven", "e5481b297b6023d446d835156591ba5ce88c17be").step); |
| 67 | 69 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses", "f46d9f774df929885eef66c733a1e2a46bf16aec").step); |
| 68 | 70 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses-text", "b01e5a2dffcc564bddd8f514fe64bab9b5c52572").step); |
| ... | ... | @@ -202,6 +204,12 @@ pub const package_data = struct { |
| 202 | 204 | .entry = "/git/github.com/nektro/zig-inquirer/cf43dd6c9f328073f7468b5341c69ed0bb185db3/src/lib.zig", |
| 203 | 205 | .deps = &[_]*Package{ &_s84v9o48ucb0 }, |
| 204 | 206 | }; |
| 207 | pub var _7l3oxw6nqqws = Package{ | |
| 208 | .store = "/git/github.com/nektro/zig-intrusive-parser/2336d8b767eb7378762e1ba63635ca44accbd2ca", | |
| 209 | .name = "intrusive-parser", | |
| 210 | .entry = "/git/github.com/nektro/zig-intrusive-parser/2336d8b767eb7378762e1ba63635ca44accbd2ca/intrusive_parser.zig", | |
| 211 | .deps = &[_]*Package{ &_f7dubzb7cyqe }, | |
| 212 | }; | |
| 205 | 213 | pub var _96h80ezrvj7i = Package{ |
| 206 | 214 | .store = "/git/github.com/nektro/zig-leven/e5481b297b6023d446d835156591ba5ce88c17be", |
| 207 | 215 | .name = "leven", |
| ... | ... | @@ -241,6 +249,12 @@ pub const package_data = struct { |
| 241 | 249 | .entry = "/git/github.com/nektro/zig-git/103f4e419c35b88f802bb8234ece1c0a9aa40c03/git.zig", |
| 242 | 250 | .deps = &[_]*Package{ &_iecwp4b3bsfm, &_f7dubzb7cyqe, &_ede2wygpe1iy }, |
| 243 | 251 | }; |
| 252 | pub var _ocmr9rtohgcc = Package{ | |
| 253 | .store = "/git/github.com/nektro/zig-json/29587071de6dd3338e8eb76d4e0307af69a2d61a", | |
| 254 | .name = "json", | |
| 255 | .entry = "/git/github.com/nektro/zig-json/29587071de6dd3338e8eb76d4e0307af69a2d61a/json.zig", | |
| 256 | .deps = &[_]*Package{ &_f7dubzb7cyqe, &_ede2wygpe1iy, &_7l3oxw6nqqws }, | |
| 257 | }; | |
| 244 | 258 | pub var _g982zq6e8wsv = Package{ |
| 245 | 259 | .store = "/git/github.com/nektro/zig-yaml/0d17fb99cba338aedc1abac12d78d5e5f04f0b6b", |
| 246 | 260 | .name = "yaml", |
| ... | ... | @@ -266,7 +280,7 @@ pub const package_data = struct { |
| 266 | 280 | pub var _89ujp8gq842x = Package{ |
| 267 | 281 | .name = "zigmod", |
| 268 | 282 | .entry = "/../..//src/lib.zig", |
| 269 | .deps = &[_]*Package{ &_g982zq6e8wsv, &_s84v9o48ucb0, &_2ta738wrqbaq, &_0npcrzfdlrvk, &_ejw82j2ipa0e, &_2ovav391ivak, &_c1xirp1ota5p, &_u7sysdckdymi, &_iecwp4b3bsfm, &_f7dubzb7cyqe, &_0k64oe2nuzvj }, | |
| 283 | .deps = &[_]*Package{ &_g982zq6e8wsv, &_s84v9o48ucb0, &_2ta738wrqbaq, &_0npcrzfdlrvk, &_ejw82j2ipa0e, &_2ovav391ivak, &_c1xirp1ota5p, &_u7sysdckdymi, &_iecwp4b3bsfm, &_f7dubzb7cyqe, &_0k64oe2nuzvj, &_ocmr9rtohgcc }, | |
| 270 | 284 | }; |
| 271 | 285 | pub var _root = Package{ |
| 272 | 286 | }; |
licenses.txt+5| ... | ... | @@ -10,6 +10,7 @@ MIT: |
| 10 | 10 | - git https://github.com/nektro/zig-extras |
| 11 | 11 | - git https://github.com/nektro/zig-git |
| 12 | 12 | - git https://github.com/nektro/zig-inquirer |
| 13 | - git https://github.com/nektro/zig-json | |
| 13 | 14 | - git https://github.com/nektro/zig-leven |
| 14 | 15 | - git https://github.com/nektro/zig-licenses |
| 15 | 16 | - git https://github.com/nektro/zig-licenses-text |
| ... | ... | @@ -19,3 +20,7 @@ MIT: |
| 19 | 20 | - git https://github.com/truemedian/hzzp |
| 20 | 21 | - git https://github.com/ziglibs/known-folders |
| 21 | 22 | - git https://github.com/yaml/libyaml |
| 23 | ||
| 24 | MPL-2.0: | |
| 25 | = https://spdx.org/licenses/MPL-2.0 | |
| 26 | - git https://github.com/nektro/zig-intrusive-parser |
src/cmd/aq.zig+8-7| ... | ... | @@ -3,6 +3,7 @@ const string = []const u8; |
| 3 | 3 | const gpa = std.heap.c_allocator; |
| 4 | 4 | const zfetch = @import("zfetch"); |
| 5 | 5 | const extras = @import("extras"); |
| 6 | const json = @import("json"); | |
| 6 | 7 | |
| 7 | 8 | const u = @import("./../util/index.zig"); |
| 8 | 9 | |
| ... | ... | @@ -43,7 +44,7 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { |
| 43 | 44 | u.fail("unknown command \"{s}\" for \"zigmod aq\"", .{args[0]}); |
| 44 | 45 | } |
| 45 | 46 | |
| 46 | pub fn server_fetch(url: string) !std.json.Parsed(std.json.Value) { | |
| 47 | pub fn server_fetch(url: string) !json.Document { | |
| 47 | 48 | const req = try zfetch.Request.init(gpa, url, null); |
| 48 | 49 | defer req.deinit(); |
| 49 | 50 | |
| ... | ... | @@ -53,13 +54,13 @@ pub fn server_fetch(url: string) !std.json.Parsed(std.json.Value) { |
| 53 | 54 | |
| 54 | 55 | try req.do(.GET, headers, null); |
| 55 | 56 | |
| 56 | const r = req.reader(); | |
| 57 | const body_content = try r.readAllAlloc(gpa, std.math.maxInt(usize)); | |
| 58 | const val = try extras.parse_json(gpa, body_content); | |
| 57 | const doc = try json.parse(gpa, "", req.reader(), .{ .support_trailing_commas = true, .maximum_depth = 100 }); | |
| 58 | doc.acquire(); | |
| 59 | defer doc.release(); | |
| 59 | 60 | |
| 60 | if (val.value.object.get("message")) |msg| { | |
| 61 | std.log.err("server: {s}", .{msg.string}); | |
| 61 | if (doc.root.object().getS("message")) |msg| { | |
| 62 | std.log.err("server: {s}", .{msg}); | |
| 62 | 63 | return error.AquilaBadResponse; |
| 63 | 64 | } |
| 64 | return val; | |
| 65 | return doc; | |
| 65 | 66 | } |
src/cmd/aquila/add.zig+5-3| ... | ... | @@ -18,11 +18,13 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { |
| 18 | 18 | |
| 19 | 19 | pub fn do(dir: std.fs.Dir, pkg_id: string) !string { |
| 20 | 20 | const url = try std.mem.join(gpa, "/", &.{ aq.server_root, pkg_id }); |
| 21 | const val = try aq.server_fetch(url); | |
| 21 | const doc = try aq.server_fetch(url); | |
| 22 | doc.acquire(); | |
| 23 | defer doc.release(); | |
| 22 | 24 | |
| 23 | 25 | const pkg_url = try std.fmt.allocPrint(gpa, "https://{s}/{s}", .{ |
| 24 | val.value.object.get("repo").?.object.get("domain").?.string, | |
| 25 | val.value.object.get("package").?.object.get("remote_name").?.string, | |
| 26 | doc.root.object().getO("repo").?.getS("domain").?, | |
| 27 | doc.root.object().getO("package").?.getS("remote_name").?, | |
| 26 | 28 | }); |
| 27 | 29 | |
| 28 | 30 | const m = try zigmod.ModFile.from_dir(gpa, dir); |
src/cmd/aquila/showjson.zig+4-2| ... | ... | @@ -12,7 +12,9 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { |
| 12 | 12 | const out = std.io.getStdOut().writer(); |
| 13 | 13 | |
| 14 | 14 | const url = try std.mem.join(gpa, "/", &.{ aq.server_root, args[0] }); |
| 15 | const val = try aq.server_fetch(url); | |
| 15 | const doc = try aq.server_fetch(url); | |
| 16 | doc.acquire(); | |
| 17 | defer doc.release(); | |
| 16 | 18 | |
| 17 | try out.print("{}\n", .{val}); | |
| 19 | try out.print("{}\n", .{doc}); | |
| 18 | 20 | } |
src/cmd/zpm.zig+26-31| ... | ... | @@ -3,6 +3,7 @@ const string = []const u8; |
| 3 | 3 | const gpa = std.heap.c_allocator; |
| 4 | 4 | const zfetch = @import("zfetch"); |
| 5 | 5 | const extras = @import("extras"); |
| 6 | const json = @import("json"); | |
| 6 | 7 | |
| 7 | 8 | const u = @import("./../util/index.zig"); |
| 8 | 9 | |
| ... | ... | @@ -26,7 +27,7 @@ pub const Package = struct { |
| 26 | 27 | root_file: string, |
| 27 | 28 | description: string, |
| 28 | 29 | source: u32, |
| 29 | links: []const ?string, | |
| 30 | links: []const string, | |
| 30 | 31 | }; |
| 31 | 32 | |
| 32 | 33 | pub fn execute(self_name: []const u8, args: [][]u8) !void { |
| ... | ... | @@ -55,60 +56,54 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { |
| 55 | 56 | u.fail("unknown command \"{s}\" for \"zigmod zpm\"", .{args[0]}); |
| 56 | 57 | } |
| 57 | 58 | |
| 58 | pub fn server_fetch(url: string) !std.json.Parsed(std.json.Value) { | |
| 59 | pub fn server_fetch(url: string) !json.Document { | |
| 59 | 60 | const req = try zfetch.Request.init(gpa, url, null); |
| 60 | 61 | defer req.deinit(); |
| 61 | 62 | try req.do(.GET, null, null); |
| 62 | const r = req.reader(); | |
| 63 | const body_content = try r.readAllAlloc(gpa, std.math.maxInt(usize)); | |
| 64 | return extras.parse_json(gpa, body_content); | |
| 63 | return json.parse(gpa, "", req.reader(), .{ .support_trailing_commas = true, .maximum_depth = 100 }); | |
| 65 | 64 | } |
| 66 | 65 | |
| 67 | 66 | pub fn server_fetchArray(url: string) ![]const Package { |
| 68 | const val = try server_fetch(url); | |
| 67 | const doc = try server_fetch(url); | |
| 68 | doc.acquire(); | |
| 69 | defer doc.release(); | |
| 69 | 70 | var list = std.ArrayList(Package).init(gpa); |
| 70 | 71 | errdefer list.deinit(); |
| 71 | 72 | |
| 72 | for (val.value.array.items) |item| { | |
| 73 | if (get(item, "root_file") == null) continue; | |
| 73 | for (doc.root.array()) |item| { | |
| 74 | const obj = item.object(); | |
| 75 | if (obj.getS("root_file") == null) continue; | |
| 74 | 76 | try list.append(Package{ |
| 75 | .name = item.object.get("name").?.string, | |
| 76 | .author = item.object.get("author").?.string, | |
| 77 | .description = item.object.get("description").?.string, | |
| 78 | .tags = try valueStrArray(item.object.get("tags").?.array.items), | |
| 79 | .git = item.object.get("git").?.string, | |
| 80 | .root_file = item.object.get("root_file").?.string, | |
| 81 | .source = @intCast(item.object.get("source").?.integer), | |
| 82 | .links = try valueLinks(item.object.get("links").?), | |
| 77 | .name = obj.getS("name").?, | |
| 78 | .author = obj.getS("author").?, | |
| 79 | .description = obj.getS("description").?, | |
| 80 | .tags = try valueStrArray(obj.getA("tags").?), | |
| 81 | .git = obj.getS("git").?, | |
| 82 | .root_file = obj.getS("root_file").?, | |
| 83 | .source = obj.getN("source").?.get(u32), | |
| 84 | .links = try valueLinks(obj.getO("links").?), | |
| 83 | 85 | }); |
| 84 | 86 | } |
| 85 | 87 | return list.toOwnedSlice(); |
| 86 | 88 | } |
| 87 | 89 | |
| 88 | fn valueStrArray(vals: []std.json.Value) ![]string { | |
| 90 | fn valueStrArray(vals: json.Array) ![]string { | |
| 89 | 91 | var list = std.ArrayList(string).init(gpa); |
| 90 | 92 | errdefer list.deinit(); |
| 91 | 93 | |
| 92 | 94 | for (vals) |item| { |
| 93 | if (item != .string) continue; | |
| 94 | try list.append(item.string); | |
| 95 | if (item.v() != .string) continue; | |
| 96 | try list.append(item.string()); | |
| 95 | 97 | } |
| 96 | 98 | return list.toOwnedSlice(); |
| 97 | 99 | } |
| 98 | 100 | |
| 99 | fn valueLinks(vals: std.json.Value) ![]?string { | |
| 100 | var list = std.ArrayList(?string).init(gpa); | |
| 101 | fn valueLinks(vals: json.ObjectIndex) ![]string { | |
| 102 | var list = std.ArrayList(string).init(gpa); | |
| 101 | 103 | errdefer list.deinit(); |
| 102 | 104 | |
| 103 | if (get(vals, "github")) |x| try list.append(x.string); | |
| 104 | if (get(vals, "aquila")) |x| try list.append(x.string); | |
| 105 | if (get(vals, "astrolabe")) |x| try list.append(x.string); | |
| 105 | if (vals.getS("github")) |x| try list.append(x); | |
| 106 | if (vals.getS("aquila")) |x| try list.append(x); | |
| 107 | if (vals.getS("astrolabe")) |x| try list.append(x); | |
| 106 | 108 | return list.toOwnedSlice(); |
| 107 | 109 | } |
| 108 | ||
| 109 | fn get(obj: std.json.Value, key: string) ?std.json.Value { | |
| 110 | const v = obj.object.get(key); | |
| 111 | if (v == null) return null; | |
| 112 | if (v.? == .null) return null; | |
| 113 | return v.?; | |
| 114 | } |
src/cmd/zpm/showjson.zig+4-2| ... | ... | @@ -12,7 +12,9 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { |
| 12 | 12 | const out = std.io.getStdOut().writer(); |
| 13 | 13 | |
| 14 | 14 | const url = try std.mem.join(gpa, "/", &.{ zpm.server_root, args[0] }); |
| 15 | const val = try zpm.server_fetch(url); | |
| 15 | const doc = try zpm.server_fetch(url); | |
| 16 | doc.acquire(); | |
| 17 | defer doc.release(); | |
| 16 | 18 | |
| 17 | try out.print("{}\n", .{val}); | |
| 19 | try out.print("{}\n", .{doc}); | |
| 18 | 20 | } |
src/cmd/zpm/tags.zig+8-6| ... | ... | @@ -14,12 +14,14 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { |
| 14 | 14 | const out = std.io.getStdOut().writer(); |
| 15 | 15 | |
| 16 | 16 | const url = try std.mem.join(gpa, "/", &.{ zpm.server_root, "tags" }); |
| 17 | const val = try zpm.server_fetch(url); | |
| 17 | const doc = try zpm.server_fetch(url); | |
| 18 | doc.acquire(); | |
| 19 | defer doc.release(); | |
| 18 | 20 | |
| 19 | 21 | const name_col_width = blk: { |
| 20 | 22 | var w: usize = 4; |
| 21 | for (val.value.array.items) |tag| { | |
| 22 | const len = tag.object.get("name").?.string.len; | |
| 23 | for (doc.root.array()) |tag| { | |
| 24 | const len = tag.object().getS("name").?.len; | |
| 23 | 25 | if (len > w) { |
| 24 | 26 | w = len; |
| 25 | 27 | } |
| ... | ... | @@ -31,11 +33,11 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { |
| 31 | 33 | try print_c_n(out, ' ', name_col_width - 4); |
| 32 | 34 | try out.writeAll("DESCRIPTION\n"); |
| 33 | 35 | |
| 34 | for (val.value.array.items) |tag| { | |
| 35 | const name = tag.object.get("name").?.string; | |
| 36 | for (doc.root.array()) |tag| { | |
| 37 | const name = tag.object().getS("name").?; | |
| 36 | 38 | try out.writeAll(name); |
| 37 | 39 | try print_c_n(out, ' ', name_col_width - name.len); |
| 38 | try out.writeAll(tag.object.get("description").?.string); | |
| 40 | try out.writeAll(tag.object().getS("description").?); | |
| 39 | 41 | try out.writeAll("\n"); |
| 40 | 42 | } |
| 41 | 43 | } |
src/util/modfile.zig+2-6| ... | ... | @@ -90,7 +90,6 @@ pub const ModFile = struct { |
| 90 | 90 | var dtype: string = undefined; |
| 91 | 91 | var path: string = undefined; |
| 92 | 92 | var version: ?string = null; |
| 93 | var name = item.mapping.get_string("name") orelse ""; | |
| 94 | 93 | var main = item.mapping.get_string("main") orelse ""; |
| 95 | 94 | |
| 96 | 95 | if (item.mapping.get("src")) |val| { |
| ... | ... | @@ -112,10 +111,6 @@ pub const ModFile = struct { |
| 112 | 111 | } |
| 113 | 112 | const dep_type = std.meta.stringToEnum(zigmod.Dep.Type, dtype).?; |
| 114 | 113 | if (dep_type == .local) { |
| 115 | if (path.len > 0) { | |
| 116 | name = path; | |
| 117 | path = ""; | |
| 118 | } | |
| 119 | 114 | if (version.?.len > 0) { |
| 120 | 115 | main = version.?; |
| 121 | 116 | version = ""; |
| ... | ... | @@ -129,7 +124,7 @@ pub const ModFile = struct { |
| 129 | 124 | .type = dep_type, |
| 130 | 125 | .path = path, |
| 131 | 126 | .id = id, |
| 132 | .name = name, | |
| 127 | .name = item.mapping.get_string("name") orelse "", | |
| 133 | 128 | .main = main, |
| 134 | 129 | .version = version.?, |
| 135 | 130 | .c_include_dirs = try item.mapping.get_string_array(alloc, "c_include_dirs"), |
| ... | ... | @@ -142,6 +137,7 @@ pub const ModFile = struct { |
| 142 | 137 | .keep = std.mem.eql(u8, "true", item.mapping.get_string("keep") orelse ""), |
| 143 | 138 | .for_build = for_build, |
| 144 | 139 | }); |
| 140 | // const d = &dep_list.getLast(); | |
| 145 | 141 | } |
| 146 | 142 | } |
| 147 | 143 | } |
zig.mod+1| ... | ... | @@ -16,6 +16,7 @@ dependencies: |
| 16 | 16 | - src: git https://github.com/nektro/zig-time |
| 17 | 17 | - src: git https://github.com/nektro/zig-extras |
| 18 | 18 | - src: git https://github.com/nektro/zig-git |
| 19 | - src: git https://github.com/nektro/zig-json | |
| 19 | 20 | |
| 20 | 21 | root_dependencies: |
| 21 | 22 | - src: git https://github.com/marlersoft/zigwin32 |
zigmod.lock+2| ... | ... | @@ -8,6 +8,8 @@ git https://github.com/nektro/zig-detect-license commit-3ff57d0681b7bd7f8ca9bd09 |
| 8 | 8 | git https://github.com/nektro/zig-extras commit-74f0ddb0a4dfa7921739b88cc381951a6b6e73ce |
| 9 | 9 | git https://github.com/nektro/zig-git commit-103f4e419c35b88f802bb8234ece1c0a9aa40c03 |
| 10 | 10 | git https://github.com/nektro/zig-inquirer commit-cf43dd6c9f328073f7468b5341c69ed0bb185db3 |
| 11 | git https://github.com/nektro/zig-intrusive-parser commit-2336d8b767eb7378762e1ba63635ca44accbd2ca | |
| 12 | git https://github.com/nektro/zig-json commit-29587071de6dd3338e8eb76d4e0307af69a2d61a | |
| 11 | 13 | git https://github.com/nektro/zig-leven commit-e5481b297b6023d446d835156591ba5ce88c17be |
| 12 | 14 | git https://github.com/nektro/zig-licenses commit-f46d9f774df929885eef66c733a1e2a46bf16aec |
| 13 | 15 | git https://github.com/nektro/zig-licenses-text commit-b01e5a2dffcc564bddd8f514fe64bab9b5c52572 |