| author | |
| committer | |
| log | 543e3137f4d4f9841089923264ff370c54136822 |
| tree | fae3f1510bba45692de0f67cab7ffbb338bf97be |
| parent | abbca727c328121a78971940e79df3e3afc56cf9 |
3 files changed, 41 insertions(+), 55 deletions(-)
deps.zig+19-7| ... | ... | @@ -30,9 +30,13 @@ pub const _ids = .{ |
| 30 | 30 | "8mdbh0zuneb0i3hs5jby5je0heem1i6yxusl7c8y8qx68hqc", |
| 31 | 31 | "s84v9o48ucb0xq0cmzq0cn433hgw0iaqztugja16h8bzxu3h", |
| 32 | 32 | "2ta738wrqbaqzl3iwzoo8nj35k9ynwz5p5iyz80ryrpp4ttf", |
| 33 | "2b7mq571jmq31ktmpigopu29480iw245heueajgxzxn7ab8o", | |
| 34 | "csbnipaad8n77buaszsnjvlmn6j173fl7pkprsctelswjywe", | |
| 35 | 33 | "0npcrzfdlrvkf44mzjo8bduj9gmqyefo0j3rstt6b0pm2r6r", |
| 34 | "ejw82j2ipa0eul25ohgdh6yy5nkrtn2pf0rq18m0079w6wj7", | |
| 35 | "9k24gimke1anv665ilg4si32ayl3dsaqgmdfdpu1ceoky8tl", | |
| 36 | "csbnipaad8n77buaszsnjvlmn6j173fl7pkprsctelswjywe", | |
| 37 | "yyhw90zkzgmubwpp87n0pzf936n850an66y1c6qan5y6sogv", | |
| 38 | "1vv8d3ee4k0g7kmy1bhi9qon55bj1arxq9181hc8sesa7x3f", | |
| 39 | "ocmr9rtohgccd6gm6tp8b1yzylyzkqwvo1q4btrsvj0cse9y", | |
| 36 | 40 | }; |
| 37 | 41 | |
| 38 | 42 | pub const _paths = .{ |
| ... | ... | @@ -40,18 +44,26 @@ pub const _paths = .{ |
| 40 | 44 | "/v/git/github.com/yaml/libyaml/tag-0.2.5/", |
| 41 | 45 | "/v/git/github.com/nektro/zig-ansi/commit-25039ca/", |
| 42 | 46 | "/v/git/github.com/ziglibs/known-folders/commit-f0f4188/", |
| 43 | "/v/git/github.com/Vexu/zuri/commit-41bcd78/", | |
| 44 | "/v/git/github.com/alexnask/iguanaTLS/commit-1767e48/", | |
| 45 | 47 | "/v/git/github.com/nektro/zig-licenses/commit-1a19e4b/", |
| 48 | "/v/git/github.com/truemedian/zfetch/commit-5b9d6a2/", | |
| 49 | "/git/github.com/truemedian/hzzp/", | |
| 50 | "/git/github.com/alexnask/iguanaTLS/", | |
| 51 | "/git/github.com/MasterQ32/zig-network/", | |
| 52 | "/git/github.com/MasterQ32/zig-uri/", | |
| 53 | "/v/git/github.com/nektro/zig-json/commit-ad4232e/", | |
| 46 | 54 | }; |
| 47 | 55 | |
| 48 | 56 | pub const package_data = struct { |
| 49 | 57 | pub const _s84v9o48ucb0xq0cmzq0cn433hgw0iaqztugja16h8bzxu3h = std.build.Pkg{ .name = "ansi", .path = cache ++ "/v/git/github.com/nektro/zig-ansi/commit-25039ca/src/lib.zig", .dependencies = &[_]std.build.Pkg{ } }; |
| 50 | 58 | pub const _2ta738wrqbaqzl3iwzoo8nj35k9ynwz5p5iyz80ryrpp4ttf = std.build.Pkg{ .name = "known-folders", .path = cache ++ "/v/git/github.com/ziglibs/known-folders/commit-f0f4188/known-folders.zig", .dependencies = &[_]std.build.Pkg{ } }; |
| 51 | pub const _2b7mq571jmq31ktmpigopu29480iw245heueajgxzxn7ab8o = std.build.Pkg{ .name = "zuri", .path = cache ++ "/v/git/github.com/Vexu/zuri/commit-41bcd78/src/zuri.zig", .dependencies = &[_]std.build.Pkg{ } }; | |
| 52 | pub const _csbnipaad8n77buaszsnjvlmn6j173fl7pkprsctelswjywe = std.build.Pkg{ .name = "iguanatls", .path = cache ++ "/v/git/github.com/alexnask/iguanaTLS/commit-1767e48/src/main.zig", .dependencies = &[_]std.build.Pkg{ } }; | |
| 53 | 59 | pub const _0npcrzfdlrvkf44mzjo8bduj9gmqyefo0j3rstt6b0pm2r6r = std.build.Pkg{ .name = "licenses", .path = cache ++ "/v/git/github.com/nektro/zig-licenses/commit-1a19e4b/src/lib.zig", .dependencies = &[_]std.build.Pkg{ } }; |
| 54 | pub const _89ujp8gq842x6mzok8feypwze138n2d96zpugw44hcq7406r = std.build.Pkg{ .name = "zigmod", .path = cache ++ "/../../src/lib.zig", .dependencies = &[_]std.build.Pkg{ _s84v9o48ucb0xq0cmzq0cn433hgw0iaqztugja16h8bzxu3h, _2ta738wrqbaqzl3iwzoo8nj35k9ynwz5p5iyz80ryrpp4ttf, _2b7mq571jmq31ktmpigopu29480iw245heueajgxzxn7ab8o, _csbnipaad8n77buaszsnjvlmn6j173fl7pkprsctelswjywe, _0npcrzfdlrvkf44mzjo8bduj9gmqyefo0j3rstt6b0pm2r6r, } }; | |
| 60 | pub const _9k24gimke1anv665ilg4si32ayl3dsaqgmdfdpu1ceoky8tl = std.build.Pkg{ .name = "hzzp", .path = cache ++ "/git/github.com/truemedian/hzzp/src/main.zig", .dependencies = &[_]std.build.Pkg{ } }; | |
| 61 | pub const _csbnipaad8n77buaszsnjvlmn6j173fl7pkprsctelswjywe = std.build.Pkg{ .name = "iguanaTLS", .path = cache ++ "/git/github.com/alexnask/iguanaTLS/src/main.zig", .dependencies = &[_]std.build.Pkg{ } }; | |
| 62 | pub const _yyhw90zkzgmubwpp87n0pzf936n850an66y1c6qan5y6sogv = std.build.Pkg{ .name = "network", .path = cache ++ "/git/github.com/MasterQ32/zig-network/network.zig", .dependencies = &[_]std.build.Pkg{ } }; | |
| 63 | pub const _1vv8d3ee4k0g7kmy1bhi9qon55bj1arxq9181hc8sesa7x3f = std.build.Pkg{ .name = "uri", .path = cache ++ "/git/github.com/MasterQ32/zig-uri/uri.zig", .dependencies = &[_]std.build.Pkg{ } }; | |
| 64 | pub const _ejw82j2ipa0eul25ohgdh6yy5nkrtn2pf0rq18m0079w6wj7 = std.build.Pkg{ .name = "zfetch", .path = cache ++ "/v/git/github.com/truemedian/zfetch/commit-5b9d6a2/src/main.zig", .dependencies = &[_]std.build.Pkg{ _9k24gimke1anv665ilg4si32ayl3dsaqgmdfdpu1ceoky8tl, _csbnipaad8n77buaszsnjvlmn6j173fl7pkprsctelswjywe, _yyhw90zkzgmubwpp87n0pzf936n850an66y1c6qan5y6sogv, _1vv8d3ee4k0g7kmy1bhi9qon55bj1arxq9181hc8sesa7x3f, } }; | |
| 65 | pub const _ocmr9rtohgccd6gm6tp8b1yzylyzkqwvo1q4btrsvj0cse9y = std.build.Pkg{ .name = "json", .path = cache ++ "/v/git/github.com/nektro/zig-json/commit-ad4232e/src/lib.zig", .dependencies = &[_]std.build.Pkg{ } }; | |
| 66 | pub const _89ujp8gq842x6mzok8feypwze138n2d96zpugw44hcq7406r = std.build.Pkg{ .name = "zigmod", .path = cache ++ "/../../src/lib.zig", .dependencies = &[_]std.build.Pkg{ _s84v9o48ucb0xq0cmzq0cn433hgw0iaqztugja16h8bzxu3h, _2ta738wrqbaqzl3iwzoo8nj35k9ynwz5p5iyz80ryrpp4ttf, _0npcrzfdlrvkf44mzjo8bduj9gmqyefo0j3rstt6b0pm2r6r, _ejw82j2ipa0eul25ohgdh6yy5nkrtn2pf0rq18m0079w6wj7, _ocmr9rtohgccd6gm6tp8b1yzylyzkqwvo1q4btrsvj0cse9y, } }; | |
| 55 | 67 | }; |
| 56 | 68 | |
| 57 | 69 | pub const packages = &[_]std.build.Pkg{ |
src/cmd/zpm_add.zig+19-45| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const gpa = std.heap.c_allocator; |
| 3 | 3 | |
| 4 | const zuri = @import("zuri"); | |
| 5 | const iguanatls = @import("iguanatls"); | |
| 4 | const zfetch = @import("zfetch"); | |
| 5 | const json = @import("json"); | |
| 6 | ||
| 6 | 7 | const u = @import("./../util/index.zig"); |
| 7 | 8 | |
| 8 | 9 | // |
| ... | ... | @@ -20,47 +21,20 @@ pub const Zpm = struct { |
| 20 | 21 | }; |
| 21 | 22 | |
| 22 | 23 | pub fn execute(args: [][]u8) !void { |
| 23 | const url = try zuri.Uri.parse("https://zpm.random-projects.net:443/api/packages", true); | |
| 24 | ||
| 25 | const sock = try std.net.tcpConnectToHost(gpa, url.host.name, url.port.?); | |
| 26 | defer sock.close(); | |
| 27 | ||
| 28 | var client = try iguanatls.client_connect(.{ | |
| 29 | .reader = sock.reader(), | |
| 30 | .writer = sock.writer(), | |
| 31 | .cert_verifier = .none, | |
| 32 | .temp_allocator = gpa, | |
| 33 | .ciphersuites = iguanatls.ciphersuites.all, | |
| 34 | }, url.host.name); | |
| 35 | defer client.close_notify() catch {}; | |
| 24 | const url = "https://zpm.random-projects.net/api/packages"; | |
| 36 | 25 | |
| 37 | const w = client.writer(); | |
| 38 | try w.print("GET {s} HTTP/1.1\r\n", .{url.path}); | |
| 39 | try w.print("Host: {s}:{}\r\n", .{ url.host.name, url.port.? }); | |
| 40 | try w.writeAll("Accept: application/json; charset=UTF-8\r\n"); | |
| 41 | try w.writeAll("Connection: close\r\n"); | |
| 42 | try w.writeAll("\r\n"); | |
| 43 | ||
| 44 | const r = client.reader(); | |
| 45 | var buf: [1]u8 = undefined; | |
| 46 | const data = &std.ArrayList(u8).init(gpa); | |
| 47 | while (true) { | |
| 48 | const len = try r.read(&buf); | |
| 49 | if (len == 0) { | |
| 50 | break; | |
| 51 | } | |
| 52 | try data.appendSlice(buf[0..len]); | |
| 53 | } | |
| 26 | const req = try zfetch.Request.init(gpa, url, null); | |
| 27 | defer req.deinit(); | |
| 54 | 28 | |
| 55 | const index = std.mem.indexOf(u8, data.items, "\r\n\r\n").?; | |
| 56 | const html_contents = data.items[index..]; | |
| 29 | try req.do(.GET, null, null); | |
| 30 | const r = req.reader(); | |
| 57 | 31 | |
| 58 | var stream = std.json.TokenStream.init(html_contents[4..]); | |
| 59 | const res = try std.json.parse([]Zpm.Package, &stream, .{ .allocator = gpa }); | |
| 32 | const body_content = try r.readAllAlloc(gpa, std.math.maxInt(usize)); | |
| 33 | const val = try json.parse(gpa, body_content); | |
| 60 | 34 | |
| 61 | 35 | const found = blk: { |
| 62 | for (res) |pkg| { | |
| 63 | if (std.mem.eql(u8, pkg.name, args[0])) { | |
| 36 | for (val.Array) |pkg| { | |
| 37 | if (std.mem.eql(u8, pkg.get("name").?.String, args[0])) { | |
| 64 | 38 | break :blk pkg; |
| 65 | 39 | } |
| 66 | 40 | } |
| ... | ... | @@ -68,12 +42,12 @@ pub fn execute(args: [][]u8) !void { |
| 68 | 42 | unreachable; |
| 69 | 43 | }; |
| 70 | 44 | |
| 71 | u.assert(found.root_file != null, "package must have an entry point to be able to be added to your dependencies", .{}); | |
| 45 | u.assert(found.get("root_file") != null, "package must have an entry point to be able to be added to your dependencies", .{}); | |
| 72 | 46 | |
| 73 | 47 | const self_module = try u.ModFile.init(gpa, "zig.mod"); |
| 74 | 48 | for (self_module.deps) |dep| { |
| 75 | if (std.mem.eql(u8, dep.name, found.name)) { | |
| 76 | u.assert(false, "dependency with name '{s}' already exists in your dependencies", .{found.name}); | |
| 49 | if (std.mem.eql(u8, dep.name, found.get("name").?.String)) { | |
| 50 | u.assert(false, "dependency with name '{s}' already exists in your dependencies", .{found.get("name").?.String}); | |
| 77 | 51 | } |
| 78 | 52 | } |
| 79 | 53 | |
| ... | ... | @@ -82,9 +56,9 @@ pub fn execute(args: [][]u8) !void { |
| 82 | 56 | |
| 83 | 57 | const file_w = file.writer(); |
| 84 | 58 | try file_w.print("\n", .{}); |
| 85 | try file_w.print(" - src: git {s}\n", .{found.git}); | |
| 86 | try file_w.print(" name: {s}\n", .{found.name}); | |
| 87 | try file_w.print(" main: {s}\n", .{found.root_file.?[1..]}); | |
| 59 | try file_w.print(" - src: git {s}\n", .{found.get("git").?.String}); | |
| 60 | try file_w.print(" name: {s}\n", .{found.get("name").?.String}); | |
| 61 | try file_w.print(" main: {s}\n", .{found.get("root_file").?.String[1..]}); | |
| 88 | 62 | |
| 89 | std.log.info("Successfully added package {s} by {s}", .{ found.name, found.author }); | |
| 63 | std.log.info("Successfully added package {s} by {s}", .{ found.get("name").?.String, found.get("author").?.String }); | |
| 90 | 64 | } |
zig.mod+3-3| ... | ... | @@ -32,11 +32,11 @@ dependencies: |
| 32 | 32 | |
| 33 | 33 | - src: git https://github.com/ziglibs/known-folders commit-f0f4188 |
| 34 | 34 | |
| 35 | - src: git https://github.com/Vexu/zuri commit-41bcd78 | |
| 35 | - src: git https://github.com/nektro/zig-licenses commit-1a19e4b | |
| 36 | 36 | |
| 37 | - src: git https://github.com/alexnask/iguanaTLS commit-1767e48 | |
| 37 | - src: git https://github.com/truemedian/zfetch commit-5b9d6a2 | |
| 38 | 38 | |
| 39 | - src: git https://github.com/nektro/zig-licenses commit-1a19e4b | |
| 39 | - src: git https://github.com/nektro/zig-json commit-ad4232e | |
| 40 | 40 | |
| 41 | 41 | dev_dependencies: |
| 42 | 42 | - src: git https://github.com/nektro/zig-ansi commit-25039ca |