aboutsummaryrefslogtreecommitdiff
path: root/src/cli
diff options
context:
space:
mode:
authorGravatar Dylan Conway <35280289+dylan-conway@users.noreply.github.com> 2023-02-23 23:57:19 -0800
committerGravatar GitHub <noreply@github.com> 2023-02-23 23:57:19 -0800
commit3f04f8d0a653cf5decef2225c2044742b382718a (patch)
tree91eb6500834e3157ecb9ab208101aa368a1191c8 /src/cli
parentb5bdde28ed34070cbb1d34d13f414f4c513ee40d (diff)
downloadbun-3f04f8d0a653cf5decef2225c2044742b382718a.tar.gz
bun-3f04f8d0a653cf5decef2225c2044742b382718a.tar.zst
bun-3f04f8d0a653cf5decef2225c2044742b382718a.zip
Upgrade Zig (#2151)
* fixup * Upgrade Zig * Remove bad assertion * strings * bump * mode -> optimize * optimize * Linux build * Update bindgen.zig
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/build_command.zig2
-rw-r--r--src/cli/bunx_command.zig10
-rw-r--r--src/cli/colon_list_type.zig2
-rw-r--r--src/cli/create_command.zig16
-rw-r--r--src/cli/init_command.zig4
-rw-r--r--src/cli/install_completions_command.zig30
-rw-r--r--src/cli/package_manager_command.zig6
-rw-r--r--src/cli/run_command.zig2
-rw-r--r--src/cli/shell_completions.zig8
-rw-r--r--src/cli/test_command.zig4
-rw-r--r--src/cli/upgrade_command.zig4
11 files changed, 44 insertions, 44 deletions
diff --git a/src/cli/build_command.zig b/src/cli/build_command.zig
index 233dd487f..c804316dc 100644
--- a/src/cli/build_command.zig
+++ b/src/cli/build_command.zig
@@ -62,7 +62,7 @@ pub const BuildCommand = struct {
var all_paths = try ctx.allocator.alloc([]const u8, result.output_files.len);
var max_path_len: usize = 0;
- for (result.output_files) |f, i| {
+ for (result.output_files, 0..) |f, i| {
all_paths[i] = f.input.text;
}
diff --git a/src/cli/bunx_command.zig b/src/cli/bunx_command.zig
index 3548702ee..ef1fc3c17 100644
--- a/src/cli/bunx_command.zig
+++ b/src/cli/bunx_command.zig
@@ -125,7 +125,7 @@ pub const BunxCommand = struct {
var passthrough_list = try std.ArrayList(string).initCapacity(ctx.allocator, std.os.argv.len -| 1);
var package_name_for_update_request = [1]string{""};
{
- var argv = std.mem.span(std.os.argv)[1..];
+ var argv = std.os.argv[1..];
var found_subcommand_name = false;
@@ -262,7 +262,7 @@ pub const BunxCommand = struct {
this_bundler.fs.top_level_dir,
absolute_in_cache_dir,
)) |destination| {
- const out = std.mem.span(destination);
+ const out = bun.asByteSlice(destination);
_ = try Run.runBinary(
ctx,
try this_bundler.fs.dirname_store.append(@TypeOf(out), out),
@@ -291,7 +291,7 @@ pub const BunxCommand = struct {
this_bundler.fs.top_level_dir,
absolute_in_cache_dir,
)) |destination| {
- const out = std.mem.span(destination);
+ const out = bun.asByteSlice(destination);
_ = try Run.runBinary(
ctx,
try this_bundler.fs.dirname_store.append(@TypeOf(out), out),
@@ -381,7 +381,7 @@ pub const BunxCommand = struct {
this_bundler.fs.top_level_dir,
absolute_in_cache_dir,
)) |destination| {
- const out = std.mem.span(destination);
+ const out = bun.asByteSlice(destination);
_ = try Run.runBinary(
ctx,
try this_bundler.fs.dirname_store.append(@TypeOf(out), out),
@@ -411,7 +411,7 @@ pub const BunxCommand = struct {
this_bundler.fs.top_level_dir,
absolute_in_cache_dir,
)) |destination| {
- const out = std.mem.span(destination);
+ const out = bun.asByteSlice(destination);
_ = try Run.runBinary(
ctx,
try this_bundler.fs.dirname_store.append(@TypeOf(out), out),
diff --git a/src/cli/colon_list_type.zig b/src/cli/colon_list_type.zig
index a76ba7fbf..1151d6a18 100644
--- a/src/cli/colon_list_type.zig
+++ b/src/cli/colon_list_type.zig
@@ -22,7 +22,7 @@ pub fn ColonListType(comptime t: type, comptime value_resolver: anytype) type {
values: []t,
pub fn load(self: *@This(), input: []const string) !void {
- for (input) |str, i| {
+ for (input, 0..) |str, i| {
// Support either ":" or "=" as the separator, preferring whichever is first.
// ":" is less confusing IMO because that syntax is used with flags
// but "=" is what esbuild uses and I want this to be somewhat familiar for people using esbuild
diff --git a/src/cli/create_command.zig b/src/cli/create_command.zig
index 95f53ffd3..af369fb8b 100644
--- a/src/cli/create_command.zig
+++ b/src/cli/create_command.zig
@@ -130,7 +130,7 @@ fn execTask(allocator: std.mem.Allocator, task_: string, cwd: string, _: string,
}
Output.pretty("\n<r><d>$<b>", .{});
- for (argv) |arg, i| {
+ for (argv, 0..) |arg, i| {
if (i > argv.len - 1) {
Output.print(" {s} ", .{arg});
} else {
@@ -165,7 +165,7 @@ pub const ProgressBuf = struct {
pub fn print(comptime fmt: string, args: anytype) !string {
buf_index += 1;
- return try std.fmt.bufPrint(std.mem.span(&bufs[buf_index % 2]), fmt, args);
+ return try std.fmt.bufPrint(&bufs[buf_index % 2], fmt, args);
}
pub fn pretty(comptime fmt: string, args: anytype) !string {
@@ -1109,7 +1109,7 @@ pub const CreateCommand = struct {
pub const bun_bun_for_nextjs_task: string = "bun bun --use next";
};
- InjectionPrefill.bun_macro_relay_object.properties = js_ast.G.Property.List.init(std.mem.span(&InjectionPrefill.bun_macro_relay_properties));
+ InjectionPrefill.bun_macro_relay_object.properties = js_ast.G.Property.List.init(InjectionPrefill.bun_macro_relay_properties[0..]);
InjectionPrefill.bun_macros_relay_object.properties = js_ast.G.Property.List.init(&InjectionPrefill.bun_macros_relay_object_properties);
InjectionPrefill.bun_macros_relay_only_object.properties = js_ast.G.Property.List.init(&InjectionPrefill.bun_macros_relay_only_object_properties);
@@ -1644,7 +1644,7 @@ pub const CreateCommand = struct {
if (create_options.open) {
if (which(&bun_path_buf, PATH, destination, "bun")) |bin| {
- var argv = [_]string{std.mem.span(bin)};
+ var argv = [_]string{bun.asByteSlice(bin)};
var child = std.ChildProcess.init(&argv, ctx.allocator);
child.cwd = destination;
child.stdin_behavior = .Inherit;
@@ -2076,7 +2076,7 @@ pub const Example = struct {
const count = q.expr.data.e_object.properties.len;
var list = try ctx.allocator.alloc(Example, count);
- for (q.expr.data.e_object.properties.slice()) |property, i| {
+ for (q.expr.data.e_object.properties.slice(), 0..) |property, i| {
const name = property.key.?.data.e_string.data;
list[i] = Example{
.name = if (std.mem.indexOfScalar(u8, name, '/')) |slash|
@@ -2204,9 +2204,9 @@ const GitHandler = struct {
if (which(&bun_path_buf, PATH, destination, "git")) |git| {
const git_commands = .{
- &[_]string{ std.mem.span(git), "init", "--quiet" },
- &[_]string{ std.mem.span(git), "add", destination, "--ignore-errors" },
- &[_]string{ std.mem.span(git), "commit", "-am", "Initial commit (via bun create)", "--quiet" },
+ &[_]string{ bun.asByteSlice(git), "init", "--quiet" },
+ &[_]string{ bun.asByteSlice(git), "add", destination, "--ignore-errors" },
+ &[_]string{ bun.asByteSlice(git), "commit", "-am", "Initial commit (via bun create)", "--quiet" },
};
if (comptime verbose) {
diff --git a/src/cli/init_command.zig b/src/cli/init_command.zig
index 9eb788dd0..33cf70caf 100644
--- a/src/cli/init_command.zig
+++ b/src/cli/init_command.zig
@@ -80,7 +80,7 @@ pub const InitCommand = struct {
}
var new = try allocator.alloc(u8, input.len);
- for (input) |c, i| {
+ for (input, 0..) |c, i| {
if (c == ' ' or c == '"' or c == '\'') {
new[i] = '-';
} else {
@@ -180,7 +180,7 @@ pub const InitCommand = struct {
for (paths_to_try) |path| {
if (exists(path)) {
- fields.entry_point = std.mem.span(path);
+ fields.entry_point = bun.asByteSlice(path);
break :infer;
}
}
diff --git a/src/cli/install_completions_command.zig b/src/cli/install_completions_command.zig
index a67a57f4f..392414686 100644
--- a/src/cli/install_completions_command.zig
+++ b/src/cli/install_completions_command.zig
@@ -133,7 +133,7 @@ pub const InstallCompletionsCommand = struct {
var completions_dir: string = "";
var output_dir: std.fs.IterableDir = found: {
- for (std.os.argv) |arg, i| {
+ for (std.os.argv, 0..) |arg, i| {
if (strings.eqlComptime(std.mem.span(arg), "completions")) {
if (std.os.argv.len > i + 1) {
const input = std.mem.span(std.os.argv[i + 1]);
@@ -167,7 +167,7 @@ pub const InstallCompletionsCommand = struct {
.fish => {
if (bun.getenvZ("XDG_CONFIG_HOME")) |config_dir| {
outer: {
- var paths = [_]string{ std.mem.span(config_dir), "./fish/completions" };
+ var paths = [_]string{ config_dir, "./fish/completions" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
break :outer;
@@ -176,7 +176,7 @@ pub const InstallCompletionsCommand = struct {
if (bun.getenvZ("XDG_DATA_HOME")) |data_dir| {
outer: {
- var paths = [_]string{ std.mem.span(data_dir), "./fish/completions" };
+ var paths = [_]string{ data_dir, "./fish/completions" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
@@ -186,7 +186,7 @@ pub const InstallCompletionsCommand = struct {
if (bun.getenvZ("HOME")) |home_dir| {
outer: {
- var paths = [_]string{ std.mem.span(home_dir), "./.config/fish/completions" };
+ var paths = [_]string{ home_dir, "./.config/fish/completions" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
break :outer;
@@ -216,7 +216,7 @@ pub const InstallCompletionsCommand = struct {
},
.zsh => {
if (bun.getenvZ("fpath")) |fpath| {
- var splitter = std.mem.split(u8, std.mem.span(fpath), " ");
+ var splitter = std.mem.split(u8, fpath, " ");
while (splitter.next()) |dir| {
completions_dir = dir;
@@ -226,7 +226,7 @@ pub const InstallCompletionsCommand = struct {
if (bun.getenvZ("XDG_DATA_HOME")) |data_dir| {
outer: {
- var paths = [_]string{ std.mem.span(data_dir), "./zsh-completions" };
+ var paths = [_]string{ data_dir, "./zsh-completions" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
@@ -245,7 +245,7 @@ pub const InstallCompletionsCommand = struct {
if (bun.getenvZ("HOME")) |home_dir| {
{
outer: {
- var paths = [_]string{ std.mem.span(home_dir), "./.oh-my-zsh/completions" };
+ var paths = [_]string{ home_dir, "./.oh-my-zsh/completions" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
break :outer;
@@ -254,7 +254,7 @@ pub const InstallCompletionsCommand = struct {
{
outer: {
- var paths = [_]string{ std.mem.span(home_dir), "./.bun" };
+ var paths = [_]string{ home_dir, "./.bun" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
break :outer;
@@ -277,7 +277,7 @@ pub const InstallCompletionsCommand = struct {
.bash => {
if (bun.getenvZ("XDG_DATA_HOME")) |data_dir| {
outer: {
- var paths = [_]string{ std.mem.span(data_dir), "./bash-completion/completions" };
+ var paths = [_]string{ data_dir, "./bash-completion/completions" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
break :outer;
@@ -286,7 +286,7 @@ pub const InstallCompletionsCommand = struct {
if (bun.getenvZ("XDG_CONFIG_HOME")) |config_dir| {
outer: {
- var paths = [_]string{ std.mem.span(config_dir), "./bash-completion/completions" };
+ var paths = [_]string{ config_dir, "./bash-completion/completions" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
@@ -297,7 +297,7 @@ pub const InstallCompletionsCommand = struct {
if (bun.getenvZ("HOME")) |home_dir| {
{
outer: {
- var paths = [_]string{ std.mem.span(home_dir), "./.oh-my-bash/custom/completions" };
+ var paths = [_]string{ home_dir, "./.oh-my-bash/custom/completions" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
@@ -306,7 +306,7 @@ pub const InstallCompletionsCommand = struct {
}
{
outer: {
- var paths = [_]string{ std.mem.span(home_dir), "./.bash_completion.d" };
+ var paths = [_]string{ home_dir, "./.bash_completion.d" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
@@ -395,7 +395,7 @@ pub const InstallCompletionsCommand = struct {
// $ZDOTDIR/.zlogout
if (bun.getenvZ("ZDOTDIR")) |zdot_dir| {
- std.mem.copy(u8, &zshrc_filepath, std.mem.span(zdot_dir));
+ std.mem.copy(u8, &zshrc_filepath, zdot_dir);
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];
@@ -405,7 +405,7 @@ pub const InstallCompletionsCommand = struct {
second: {
if (bun.getenvZ("HOME")) |zdot_dir| {
- std.mem.copy(u8, &zshrc_filepath, std.mem.span(zdot_dir));
+ std.mem.copy(u8, &zshrc_filepath, zdot_dir);
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];
@@ -415,7 +415,7 @@ pub const InstallCompletionsCommand = struct {
third: {
if (bun.getenvZ("HOME")) |zdot_dir| {
- std.mem.copy(u8, &zshrc_filepath, std.mem.span(zdot_dir));
+ std.mem.copy(u8, &zshrc_filepath, zdot_dir);
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];
diff --git a/src/cli/package_manager_command.zig b/src/cli/package_manager_command.zig
index d783b86c9..a3d3a4cb6 100644
--- a/src/cli/package_manager_command.zig
+++ b/src/cli/package_manager_command.zig
@@ -91,7 +91,7 @@ pub const PackageManagerCommand = struct {
}
if (strings.eqlComptime(subcommand, "bin")) {
- var output_path = Path.joinAbs(Fs.FileSystem.instance.top_level_dir, .auto, std.mem.span(pm.options.bin_path));
+ var output_path = Path.joinAbs(Fs.FileSystem.instance.top_level_dir, .auto, bun.asByteSlice(pm.options.bin_path));
Output.prettyln("{s}", .{output_path});
if (Output.stdout_descriptor_type == .terminal) {
Output.prettyln("\n", .{});
@@ -208,7 +208,7 @@ pub const PackageManagerCommand = struct {
const names = lockfile.packages.items(.name);
const string_bytes = lockfile.buffers.string_bytes.items;
- for (package_ids) |package_id, i| {
+ for (package_ids, 0..) |package_id, i| {
if (package_id >= lockfile.packages.len) continue;
if (i == package_ids.len - 1) {
@@ -308,7 +308,7 @@ fn printNodeModulesFolderStructure(
}
}
- for (directory.dependencies) |dependency_id, index| {
+ for (directory.dependencies, 0..) |dependency_id, index| {
const package_name_ = lockfile.buffers.dependencies.items[dependency_id].name.slice(string_bytes);
const package_name = allocator.alloc(u8, package_name_.len) catch unreachable;
defer allocator.free(package_name);
diff --git a/src/cli/run_command.zig b/src/cli/run_command.zig
index c266c8611..0da28b21a 100644
--- a/src/cli/run_command.zig
+++ b/src/cli/run_command.zig
@@ -1061,7 +1061,7 @@ pub const RunCommand = struct {
// // file.close();
- const out = std.mem.span(destination);
+ const out = bun.asByteSlice(destination);
return try runBinary(
ctx,
try this_bundler.fs.dirname_store.append(@TypeOf(out), out),
diff --git a/src/cli/shell_completions.zig b/src/cli/shell_completions.zig
index 6a4b2128f..1ac9cb2c3 100644
--- a/src/cli/shell_completions.zig
+++ b/src/cli/shell_completions.zig
@@ -22,9 +22,9 @@ pub const Shell = enum {
pub fn completions(this: Shell) []const u8 {
return switch (this) {
- .bash => std.mem.span(bash_completions),
- .zsh => std.mem.span(zsh_completions),
- .fish => std.mem.span(fish_completions),
+ .bash => bun.asByteSlice(bash_completions),
+ .zsh => bun.asByteSlice(zsh_completions),
+ .fish => bun.asByteSlice(fish_completions),
else => "",
};
}
@@ -63,7 +63,7 @@ pub fn print(this: @This()) void {
}
if (this.commands.len > 1) {
- for (this.commands[1..]) |cmd, i| {
+ for (this.commands[1..], 0..) |cmd, i| {
writer.writeAll(delimiter) catch return;
writer.writeAll(cmd) catch return;
diff --git a/src/cli/test_command.zig b/src/cli/test_command.zig
index f5760dfea..fbdf73ba3 100644
--- a/src/cli/test_command.zig
+++ b/src/cli/test_command.zig
@@ -113,7 +113,7 @@ pub const CommandLineReporter = struct {
const color_code = comptime if (skip) "<d>" else "";
if (Output.enable_ansi_colors_stderr) {
- for (scopes) |_, i| {
+ for (scopes, 0..) |_, i| {
const index = (scopes.len - 1) - i;
const scope = scopes[index];
if (scope.label.len == 0) continue;
@@ -125,7 +125,7 @@ pub const CommandLineReporter = struct {
writer.writeAll(" >") catch unreachable;
}
} else {
- for (scopes) |_, i| {
+ for (scopes, 0..) |_, i| {
const index = (scopes.len - 1) - i;
const scope = scopes[index];
if (scope.label.len == 0) continue;
diff --git a/src/cli/upgrade_command.zig b/src/cli/upgrade_command.zig
index 4880e8770..a9bf340b9 100644
--- a/src/cli/upgrade_command.zig
+++ b/src/cli/upgrade_command.zig
@@ -544,10 +544,10 @@ pub const UpgradeCommand = struct {
// xattrs are used for codesigning
// it'd be easy to mess that up
var unzip_argv = [_]string{
- std.mem.span(unzip_exe),
+ bun.asByteSlice(unzip_exe),
"-q",
"-o",
- std.mem.span(tmpname),
+ tmpname,
};
var unzip_process = std.ChildProcess.init(&unzip_argv, ctx.allocator);