diff options
author | 2022-03-04 00:20:22 -0800 | |
---|---|---|
committer | 2022-03-04 00:20:22 -0800 | |
commit | 51fbbea1d3dc2b610fe5fe525229e56b581e5c8a (patch) | |
tree | c75e063c4eb7c99737fbf7a5a2014f9546e2e218 /src/cli | |
parent | 696710fd7aedee6054947aab002aaa853e9ee731 (diff) | |
download | bun-jarred/upgrade-zig-2.tar.gz bun-jarred/upgrade-zig-2.tar.zst bun-jarred/upgrade-zig-2.zip |
upgrade zigjarred/upgrade-zig-2
Diffstat (limited to 'src/cli')
-rw-r--r-- | src/cli/create_command.zig | 17 | ||||
-rw-r--r-- | src/cli/install_completions_command.zig | 6 | ||||
-rw-r--r-- | src/cli/run_command.zig | 6 | ||||
-rw-r--r-- | src/cli/upgrade_command.zig | 4 |
4 files changed, 16 insertions, 17 deletions
diff --git a/src/cli/create_command.zig b/src/cli/create_command.zig index 3e39ae1b3..f81832b0c 100644 --- a/src/cli/create_command.zig +++ b/src/cli/create_command.zig @@ -44,6 +44,7 @@ const Headers = @import("http").Headers; const CopyFile = @import("../copy_file.zig"); var bun_path_buf: [_global.MAX_PATH_BYTES]u8 = undefined; const Futex = @import("../futex.zig"); +const ComptimeStringMap = @import("../comptime_string_map.zig").ComptimeStringMap; const target_nextjs_version = "12.1.0"; pub var initialized_store = false; @@ -378,7 +379,7 @@ pub const CreateCommand = struct { const destination = try filesystem.dirname_store.append([]const u8, resolve_path.joinAbs(filesystem.top_level_dir, .auto, dirname)); var progress = std.Progress{}; - var node = try progress.start(try ProgressBuf.print("Loading {s}", .{template}), 0); + var node = progress.start(try ProgressBuf.print("Loading {s}", .{template}), 0); progress.supports_ansi_escape_codes = Output.enable_ansi_colors_stderr; // alacritty is fast @@ -616,7 +617,7 @@ pub const CreateCommand = struct { defer outfile.close(); defer node_.completeOne(); - var infile = try entry.dir.openFile(entry.basename, .{ .read = true }); + var infile = try entry.dir.openFile(entry.basename, .{ .mode = .read_only }); defer infile.close(); // Assumption: you only really care about making sure something that was executable is still executable @@ -640,7 +641,7 @@ pub const CreateCommand = struct { try FileCopier.copy(destination_dir, &walker_, node, &progress); - package_json_file = destination_dir.openFile("package.json", .{ .read = true, .write = true }) catch null; + package_json_file = destination_dir.openFile("package.json", .{ .mode = .read_write }) catch null; read_package_json: { if (package_json_file) |pkg| { @@ -765,7 +766,7 @@ pub const CreateCommand = struct { var has_react_scripts = false; const Prune = struct { - pub const packages = std.ComptimeStringMap(void, .{ + pub const packages = ComptimeStringMap(void, .{ .{ "@parcel/babel-preset", void{} }, .{ "@parcel/core", void{} }, .{ "@swc/cli", void{} }, @@ -1249,7 +1250,7 @@ pub const CreateCommand = struct { var public_index_html_parts = [_]string{ destination, "public/index.html" }; var public_index_html_path = filesystem.absBuf(&public_index_html_parts, &bun_path_buf); - const public_index_html_file = std.fs.openFileAbsolute(public_index_html_path, .{ .read = true, .write = true }) catch break :bail; + const public_index_html_file = std.fs.openFileAbsolute(public_index_html_path, .{ .mode = .read_write }) catch break :bail; defer public_index_html_file.close(); const file_extensions_to_try = [_]string{ ".tsx", ".ts", ".jsx", ".js", ".mts", ".mcjs" }; @@ -1759,9 +1760,7 @@ pub const Example = struct { var path: [:0]u8 = home_dir_buf[0 .. entry.name.len + 1 + "package.json".len :0]; - folder.accessZ(path, .{ - .read = true, - }) catch continue :loop; + folder.accessZ(path, .{ .mode = .read_only }) catch continue :loop; try examples.append( Example{ @@ -2113,7 +2112,7 @@ pub const CreateListExamplesCommand = struct { const time = std.time.nanoTimestamp(); var progress = std.Progress{}; - var node = try progress.start("Fetching manifest", 0); + var node = progress.start("Fetching manifest", 0); progress.supports_ansi_escape_codes = Output.enable_ansi_colors_stderr; progress.refresh(); diff --git a/src/cli/install_completions_command.zig b/src/cli/install_completions_command.zig index 23b9a9a34..385d5c40e 100644 --- a/src/cli/install_completions_command.zig +++ b/src/cli/install_completions_command.zig @@ -305,7 +305,7 @@ pub const InstallCompletionsCommand = struct { std.mem.copy(u8, zshrc_filepath[zdot_dir.len..], "/.zshrc"); zshrc_filepath[zdot_dir.len + "/.zshrc".len] = 0; var filepath = zshrc_filepath[0 .. zdot_dir.len + "/.zshrc".len :0]; - break :zshrc std.fs.openFileAbsoluteZ(filepath, .{ .read = true, .write = true }) catch break :first; + break :zshrc std.fs.openFileAbsoluteZ(filepath, .{ .mode = .read_write }) catch break :first; } } @@ -315,7 +315,7 @@ pub const InstallCompletionsCommand = struct { std.mem.copy(u8, zshrc_filepath[zdot_dir.len..], "/.zshrc"); zshrc_filepath[zdot_dir.len + "/.zshrc".len] = 0; var filepath = zshrc_filepath[0 .. zdot_dir.len + "/.zshrc".len :0]; - break :zshrc std.fs.openFileAbsoluteZ(filepath, .{ .read = true, .write = true }) catch break :second; + break :zshrc std.fs.openFileAbsoluteZ(filepath, .{ .mode = .read_write }) catch break :second; } } @@ -325,7 +325,7 @@ pub const InstallCompletionsCommand = struct { std.mem.copy(u8, zshrc_filepath[zdot_dir.len..], "/.zshenv"); zshrc_filepath[zdot_dir.len + "/.zshenv".len] = 0; var filepath = zshrc_filepath[0 .. zdot_dir.len + "/.zshenv".len :0]; - break :zshrc std.fs.openFileAbsoluteZ(filepath, .{ .read = true, .write = true }) catch break :third; + break :zshrc std.fs.openFileAbsoluteZ(filepath, .{ .mode = .read_write }) catch break :third; } } diff --git a/src/cli/run_command.zig b/src/cli/run_command.zig index 8a8451cea..e1e4bf22c 100644 --- a/src/cli/run_command.zig +++ b/src/cli/run_command.zig @@ -591,7 +591,7 @@ pub const RunCommand = struct { var file_path = script_name_to_search; const file_: std.fs.File.OpenError!std.fs.File = brk: { if (script_name_to_search[0] == std.fs.path.sep) { - break :brk std.fs.openFileAbsolute(script_name_to_search, .{ .read = true }); + break :brk std.fs.openFileAbsolute(script_name_to_search, .{ .mode = .read_only }); } else { const cwd = std.os.getcwd(&path_buf) catch break :possibly_open_with_bun_js; path_buf[cwd.len] = std.fs.path.sep; @@ -605,7 +605,7 @@ pub const RunCommand = struct { if (file_path.len == 0) break :possibly_open_with_bun_js; path_buf2[file_path.len] = 0; var file_pathZ = path_buf2[0..file_path.len :0]; - break :brk std.fs.openFileAbsoluteZ(file_pathZ, .{ .read = true }); + break :brk std.fs.openFileAbsoluteZ(file_pathZ, .{ .mode = .read_only }); } }; @@ -925,7 +925,7 @@ pub const RunCommand = struct { if (path_for_which.len > 0) { if (which(&path_buf, path_for_which, this_bundler.fs.top_level_dir, script_name_to_search)) |destination| { - // var file = std.fs.openFileAbsoluteZ(destination, .{ .read = true }) catch |err| { + // var file = std.fs.openFileAbsoluteZ(destination, .{ .mode = .read_only }) catch |err| { // if (!log_errors) return false; // Output.prettyErrorln("<r>error: <red>{s}<r> opening file: \"{s}\"", .{ err, std.mem.span(destination) }); diff --git a/src/cli/upgrade_command.zig b/src/cli/upgrade_command.zig index d6e2527fe..ce05a1dfc 100644 --- a/src/cli/upgrade_command.zig +++ b/src/cli/upgrade_command.zig @@ -366,7 +366,7 @@ pub const UpgradeCommand = struct { { var refresher = std.Progress{}; - var progress = try refresher.start("Fetching version tags", 0); + var progress = refresher.start("Fetching version tags", 0); version = (try getLatestVersion(ctx.allocator, &env_loader, &refresher, progress, false)) orelse return; @@ -399,7 +399,7 @@ pub const UpgradeCommand = struct { Output.flush(); var refresher = std.Progress{}; - var progress = try refresher.start("Downloading", version.size); + var progress = refresher.start("Downloading", version.size); refresher.refresh(); var async_http = ctx.allocator.create(HTTP.AsyncHTTP) catch unreachable; var zip_file_buffer = try ctx.allocator.create(MutableString); |