╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ try.zig ──────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
138 .event = .{ 139 .repo = .{ 140 .user_id = &user_ids[r.user_index], 141 .name = r.name, 142 .description = r.description, 143 .enable_issue = true, 144 }, 145 }, 146 }; 147 } 148 149 // insert users and repos as commits in the repo 150 { 151 var json: std.Io.Writer.Allocating = .init(allocator); 152 defer json.deinit(); 153 154 for (events_to_consume) |event| { 155 json.clearRetainingCapacity(); 156 157 try std.json.Stringify.value(event, .{}, &json.writer); 158 159 // commit the event into a special branch 160 _ = try repo.commitAtRef(io, allocator, .{ .message = json.written() }, null, .{ .kind = .head, .name = "haxy/meta" }); 161 } 162 } 163 164 // consume events into the database 165 try evt.consume(repo_opts, io, allocator, &repo, .{ .kind = .head, .name = "haxy/meta" }); 166 167 break :blk .{ .user_repo = try .init(repo_opts, &page_arena, &repo) }; 168 }; 169 170 // start the server 171 172 var null_writer = std.Io.Writer.Discarding.init(&.{}); 173 var environ_map = std.process.Environ.Map.init(allocator); 174 defer environ_map.deinit(); 175 const run_opts = hx.main.RunOpts{ .out = &null_writer.writer, .err = &null_writer.writer, .environ_map = &environ_map }; 176 177 const server_path = try std.fs.path.join(allocator, &.{ cwd_path, temp_dir_name, "server" }); 178 defer allocator.free(server_path); 179 180 const Runnable = struct { 181 io: std.Io, 182 allocator: std.mem.Allocator, 183 page: *const Page, 184 185 pub fn run(self: @This()) !void { 186 // launch the TUI 187 try hx.ui.run(self.io, self.allocator, self.page); 188 } 189 }; 190 191 try srv.run(.xit, .{}, io, allocator, cwd_path, .{ 192 .data_dir = server_path, 193 }, run_opts.err, Runnable{ .io = io, .allocator = allocator, .page = &page }); 194 } 195