aboutsummaryrefslogtreecommitdiff
path: root/src/install
diff options
context:
space:
mode:
Diffstat (limited to 'src/install')
-rw-r--r--src/install/bin.zig8
-rw-r--r--src/install/extract_tarball.zig6
-rw-r--r--src/install/install.zig57
-rw-r--r--src/install/lockfile.zig37
-rw-r--r--src/install/resolvers/folder_resolver.zig6
-rw-r--r--src/install/semver.zig20
6 files changed, 66 insertions, 68 deletions
diff --git a/src/install/bin.zig b/src/install/bin.zig
index d3703f871..d7d99d480 100644
--- a/src/install/bin.zig
+++ b/src/install/bin.zig
@@ -10,7 +10,7 @@ const C = @import("../c.zig");
const Fs = @import("../fs.zig");
const stringZ = @import("../global.zig").stringZ;
const Resolution = @import("./resolution.zig").Resolution;
-const _global = @import("../global.zig");
+const bun = @import("../global.zig");
/// Normalized `bin` field in [package.json](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#bin)
/// Can be a:
/// - file path (relative to the package root)
@@ -149,7 +149,7 @@ pub const Bin = extern struct {
dir_iterator: ?std.fs.Dir.Iterator = null,
package_name: String,
package_installed_node_modules: std.fs.Dir = std.fs.Dir{ .fd = std.math.maxInt(std.os.fd_t) },
- buf: [_global.MAX_PATH_BYTES]u8 = undefined,
+ buf: [bun.MAX_PATH_BYTES]u8 = undefined,
string_buffer: []const u8,
extern_string_buf: []const ExternalString,
@@ -263,8 +263,8 @@ pub const Bin = extern struct {
// That way, if you move your node_modules folder around, the symlinks in .bin still work
// If we used absolute paths for the symlinks, you'd end up with broken symlinks
pub fn link(this: *Linker, link_global: bool) void {
- var target_buf: [_global.MAX_PATH_BYTES]u8 = undefined;
- var dest_buf: [_global.MAX_PATH_BYTES]u8 = undefined;
+ var target_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
+ var dest_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
var from_remain: []u8 = &target_buf;
var remain: []u8 = &dest_buf;
diff --git a/src/install/extract_tarball.zig b/src/install/extract_tarball.zig
index 6b2e11f70..b58596540 100644
--- a/src/install/extract_tarball.zig
+++ b/src/install/extract_tarball.zig
@@ -12,7 +12,7 @@ const Npm = @import("./npm.zig");
const ExtractTarball = @This();
const default_allocator = @import("../global.zig").default_allocator;
const Global = @import("../global.zig").Global;
-const _global = @import("../global.zig");
+const bun = @import("../global.zig");
name: strings.StringOrTinyString,
resolution: Resolution,
registry: string,
@@ -140,8 +140,8 @@ pub fn buildURLWithPrinter(
}
}
-threadlocal var abs_buf: [_global.MAX_PATH_BYTES]u8 = undefined;
-threadlocal var abs_buf2: [_global.MAX_PATH_BYTES]u8 = undefined;
+threadlocal var abs_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
+threadlocal var abs_buf2: [bun.MAX_PATH_BYTES]u8 = undefined;
fn extract(this: *const ExtractTarball, tgz_bytes: []const u8) !string {
var tmpdir = this.temp_dir;
diff --git a/src/install/install.zig b/src/install/install.zig
index 1e04a8932..9fbd4f773 100644
--- a/src/install/install.zig
+++ b/src/install/install.zig
@@ -1,13 +1,13 @@
-const _global = @import("../global.zig");
-const string = _global.string;
-const Output = _global.Output;
-const Global = _global.Global;
-const Environment = _global.Environment;
-const strings = _global.strings;
-const MutableString = _global.MutableString;
-const stringZ = _global.stringZ;
-const default_allocator = _global.default_allocator;
-const C = _global.C;
+const bun = @import("../global.zig");
+const string = bun.string;
+const Output = bun.Output;
+const Global = bun.Global;
+const Environment = bun.Environment;
+const strings = bun.strings;
+const MutableString = bun.MutableString;
+const stringZ = bun.stringZ;
+const default_allocator = bun.default_allocator;
+const C = bun.C;
const std = @import("std");
const JSLexer = @import("../js_lexer.zig");
@@ -30,13 +30,12 @@ const NodeModuleBundle = @import("../node_module_bundle.zig").NodeModuleBundle;
const DotEnv = @import("../env_loader.zig");
const which = @import("../which.zig").which;
const Run = @import("../bun_js.zig").Run;
-const NewBunQueue = @import("../bun_queue.zig").NewBunQueue;
const HeaderBuilder = @import("http").HeaderBuilder;
const Fs = @import("../fs.zig");
const FileSystem = Fs.FileSystem;
const Lock = @import("../lock.zig").Lock;
-var path_buf: [_global.MAX_PATH_BYTES]u8 = undefined;
-var path_buf2: [_global.MAX_PATH_BYTES]u8 = undefined;
+var path_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
+var path_buf2: [bun.MAX_PATH_BYTES]u8 = undefined;
const URL = @import("../query_string_map.zig").URL;
const AsyncHTTP = @import("http").AsyncHTTP;
const HTTPChannel = @import("http").HTTPChannel;
@@ -587,8 +586,8 @@ const PackageInstall = struct {
var this: *PackageInstall.Task = @fieldParentPtr(PackageInstall.Task, "task", task);
var ctx = this.ctx;
- var destination_dir_subpath_buf: [_global.MAX_PATH_BYTES]u8 = undefined;
- var cache_dir_subpath_buf: [_global.MAX_PATH_BYTES]u8 = undefined;
+ var destination_dir_subpath_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
+ var cache_dir_subpath_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
const name = ctx.names[this.package_id].slice(ctx.string_buf);
const resolution = ctx.resolutions[this.package_id];
std.mem.copy(u8, &destination_dir_subpath_buf, name);
@@ -811,7 +810,7 @@ const PackageInstall = struct {
walker: *Walker,
) !u32 {
var real_file_count: u32 = 0;
- var stackpath: [_global.MAX_PATH_BYTES]u8 = undefined;
+ var stackpath: [bun.MAX_PATH_BYTES]u8 = undefined;
while (try walker.next()) |entry| {
switch (entry.kind) {
.Directory => std.os.mkdirat(destination_dir_.fd, entry.path, 0o755) catch {},
@@ -1284,7 +1283,7 @@ pub const PackageManager = struct {
}
}
- var cached_package_folder_name_buf: [_global.MAX_PATH_BYTES]u8 = undefined;
+ var cached_package_folder_name_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
pub inline fn getCacheDirectory(this: *PackageManager) std.fs.Dir {
return this.cache_directory_ orelse brk: {
@@ -2562,14 +2561,14 @@ pub const PackageManager = struct {
}
if (std.os.getenvZ("BUN_INSTALL")) |home_dir| {
- var buf: [_global.MAX_PATH_BYTES]u8 = undefined;
+ var buf: [bun.MAX_PATH_BYTES]u8 = undefined;
var parts = [_]string{ "install", "global" };
var path = Path.joinAbsStringBuf(home_dir, &buf, &parts, .auto);
return try std.fs.cwd().makeOpenPath(path, .{ .iterate = true });
}
if (std.os.getenvZ("XDG_CACHE_HOME") orelse std.os.getenvZ("HOME")) |home_dir| {
- var buf: [_global.MAX_PATH_BYTES]u8 = undefined;
+ var buf: [bun.MAX_PATH_BYTES]u8 = undefined;
var parts = [_]string{ ".bun", "install", "global" };
var path = Path.joinAbsStringBuf(home_dir, &buf, &parts, .auto);
return try std.fs.cwd().makeOpenPath(path, .{ .iterate = true });
@@ -2592,7 +2591,7 @@ pub const PackageManager = struct {
}
if (std.os.getenvZ("BUN_INSTALL")) |home_dir| {
- var buf: [_global.MAX_PATH_BYTES]u8 = undefined;
+ var buf: [bun.MAX_PATH_BYTES]u8 = undefined;
var parts = [_]string{
"bin",
};
@@ -2601,7 +2600,7 @@ pub const PackageManager = struct {
}
if (std.os.getenvZ("XDG_CACHE_HOME") orelse std.os.getenvZ("HOME")) |home_dir| {
- var buf: [_global.MAX_PATH_BYTES]u8 = undefined;
+ var buf: [bun.MAX_PATH_BYTES]u8 = undefined;
var parts = [_]string{
".bun",
"bin",
@@ -3461,8 +3460,8 @@ pub const PackageManager = struct {
}
if (args.option("--cwd")) |cwd_| {
- var buf: [_global.MAX_PATH_BYTES]u8 = undefined;
- var buf2: [_global.MAX_PATH_BYTES]u8 = undefined;
+ var buf: [bun.MAX_PATH_BYTES]u8 = undefined;
+ var buf2: [bun.MAX_PATH_BYTES]u8 = undefined;
var final_path: [:0]u8 = undefined;
if (cwd_.len > 0 and cwd_[0] == '.') {
var cwd = try std.os.getcwd(&buf);
@@ -3955,7 +3954,7 @@ pub const PackageManager = struct {
if (op == .remove) {
var cwd = std.fs.cwd();
// This is not exactly correct
- var node_modules_buf: [_global.MAX_PATH_BYTES]u8 = undefined;
+ var node_modules_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
std.mem.copy(u8, &node_modules_buf, "node_modules" ++ std.fs.path.sep_str);
var offset_buf: []u8 = node_modules_buf["node_modules/".len..];
const name_hashes = manager.lockfile.packages.items(.name_hash);
@@ -4002,8 +4001,8 @@ pub const PackageManager = struct {
}
}
- var cwd_buf: [_global.MAX_PATH_BYTES]u8 = undefined;
- var package_json_cwd_buf: [_global.MAX_PATH_BYTES]u8 = undefined;
+ var cwd_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
+ var package_json_cwd_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
pub inline fn install(
ctx: Command.Context,
@@ -4050,8 +4049,8 @@ pub const PackageManager = struct {
node: *Progress.Node,
has_created_bin: bool = false,
global_bin_dir: std.fs.Dir,
- destination_dir_subpath_buf: [_global.MAX_PATH_BYTES]u8 = undefined,
- folder_path_buf: [_global.MAX_PATH_BYTES]u8 = undefined,
+ destination_dir_subpath_buf: [bun.MAX_PATH_BYTES]u8 = undefined,
+ folder_path_buf: [bun.MAX_PATH_BYTES]u8 = undefined,
install_count: usize = 0,
successfully_installed: Bitset,
@@ -4522,7 +4521,7 @@ pub const PackageManager = struct {
pub fn setupGlobalDir(manager: *PackageManager, ctx: *const Command.Context) !void {
manager.options.global_bin_dir = try Options.openGlobalBinDir(ctx.install);
- var out_buffer: [_global.MAX_PATH_BYTES]u8 = undefined;
+ var out_buffer: [bun.MAX_PATH_BYTES]u8 = undefined;
var result = try std.os.getFdPath(manager.options.global_bin_dir.fd, &out_buffer);
out_buffer[result.len] = 0;
var result_: [:0]u8 = out_buffer[0..result.len :0];
diff --git a/src/install/lockfile.zig b/src/install/lockfile.zig
index 382f759da..3a342498a 100644
--- a/src/install/lockfile.zig
+++ b/src/install/lockfile.zig
@@ -1,13 +1,13 @@
-const _global = @import("../global.zig");
-const string = _global.string;
-const Output = _global.Output;
-const Global = _global.Global;
-const Environment = _global.Environment;
-const strings = _global.strings;
-const MutableString = _global.MutableString;
-const stringZ = _global.stringZ;
-const default_allocator = _global.default_allocator;
-const C = _global.C;
+const bun = @import("../global.zig");
+const string = bun.string;
+const Output = bun.Output;
+const Global = bun.Global;
+const Environment = bun.Environment;
+const strings = bun.strings;
+const MutableString = bun.MutableString;
+const stringZ = bun.stringZ;
+const default_allocator = bun.default_allocator;
+const C = bun.C;
const std = @import("std");
const JSLexer = @import("../js_lexer.zig");
@@ -30,13 +30,12 @@ const NodeModuleBundle = @import("../node_module_bundle.zig").NodeModuleBundle;
const DotEnv = @import("../env_loader.zig");
const which = @import("../which.zig").which;
const Run = @import("../bun_js.zig").Run;
-const NewBunQueue = @import("../bun_queue.zig").NewBunQueue;
const HeaderBuilder = @import("http").HeaderBuilder;
const Fs = @import("../fs.zig");
const FileSystem = Fs.FileSystem;
const Lock = @import("../lock.zig").Lock;
-var path_buf: [_global.MAX_PATH_BYTES]u8 = undefined;
-var path_buf2: [_global.MAX_PATH_BYTES]u8 = undefined;
+var path_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
+var path_buf2: [bun.MAX_PATH_BYTES]u8 = undefined;
const URL = @import("../query_string_map.zig").URL;
const AsyncHTTP = @import("http").AsyncHTTP;
const HTTPChannel = @import("http").HTTPChannel;
@@ -222,13 +221,13 @@ pub const Tree = struct {
package_ids: []const PackageID,
names: []const String,
tree_id: Id = 0,
- path_buf: [_global.MAX_PATH_BYTES]u8 = undefined,
+ path_buf: [bun.MAX_PATH_BYTES]u8 = undefined,
path_buf_len: usize = 0,
last_parent: Id = invalid_id,
string_buf: string,
// max number of node_modules folders
- depth_stack: [(_global.MAX_PATH_BYTES / "node_modules".len) + 1]Id = undefined,
+ depth_stack: [(bun.MAX_PATH_BYTES / "node_modules".len) + 1]Id = undefined,
pub fn init(
trees: []const Tree,
@@ -842,8 +841,8 @@ pub const Printer = struct {
pub const Format = enum { yarn };
- var lockfile_path_buf1: [_global.MAX_PATH_BYTES]u8 = undefined;
- var lockfile_path_buf2: [_global.MAX_PATH_BYTES]u8 = undefined;
+ var lockfile_path_buf1: [bun.MAX_PATH_BYTES]u8 = undefined;
+ var lockfile_path_buf2: [bun.MAX_PATH_BYTES]u8 = undefined;
pub fn print(
allocator: std.mem.Allocator,
@@ -2282,7 +2281,7 @@ pub const Package = extern struct {
// If it's a folder, pessimistically assume we will need a maximum path
if (Dependency.Version.Tag.infer(value) == .folder) {
- string_builder.cap += _global.MAX_PATH_BYTES;
+ string_builder.cap += bun.MAX_PATH_BYTES;
}
}
total_dependencies_count += @truncate(u32, dependencies_q.expr.data.e_object.properties.len);
@@ -2911,7 +2910,7 @@ pub const Serializer = struct {
load_workspace: {
const workspace_path_len = reader.readIntLittle(u64) catch break :load_workspace;
- if (workspace_path_len > 0 and workspace_path_len < _global.MAX_PATH_BYTES) {
+ if (workspace_path_len > 0 and workspace_path_len < bun.MAX_PATH_BYTES) {
var workspace_path = try allocator.alloc(u8, workspace_path_len);
const len = reader.readAll(workspace_path) catch break :load_workspace;
lockfile.workspace_path = workspace_path[0..len];
diff --git a/src/install/resolvers/folder_resolver.zig b/src/install/resolvers/folder_resolver.zig
index 59cddf206..1c82e6b4f 100644
--- a/src/install/resolvers/folder_resolver.zig
+++ b/src/install/resolvers/folder_resolver.zig
@@ -12,7 +12,7 @@ const IdentityContext = @import("../../identity_context.zig").IdentityContext;
const strings = @import("strings");
const Resolution = @import("../resolution.zig").Resolution;
const String = @import("../semver.zig").String;
-const _global = @import("../../global.zig");
+const bun = @import("../../global.zig");
pub const FolderResolution = union(Tag) {
package_id: PackageID,
new_package_id: PackageID,
@@ -51,11 +51,11 @@ pub const FolderResolution = union(Tag) {
// We consider it valid if there is a package.json in the folder
const normalized = std.mem.trimRight(u8, normalize(non_normalized_path), std.fs.path.sep_str);
- var joined: [_global.MAX_PATH_BYTES]u8 = undefined;
+ var joined: [bun.MAX_PATH_BYTES]u8 = undefined;
var abs: string = "";
var rel: string = "";
if (strings.startsWithChar(normalized, '.')) {
- var tempcat: [_global.MAX_PATH_BYTES]u8 = undefined;
+ var tempcat: [bun.MAX_PATH_BYTES]u8 = undefined;
std.mem.copy(u8, &tempcat, normalized);
tempcat[normalized.len] = std.fs.path.sep;
diff --git a/src/install/semver.zig b/src/install/semver.zig
index 0c0f18e7d..8e06b78ce 100644
--- a/src/install/semver.zig
+++ b/src/install/semver.zig
@@ -1,13 +1,13 @@
-const _global = @import("../global.zig");
-const string = _global.string;
-const Output = _global.Output;
-const Global = _global.Global;
-const Environment = _global.Environment;
-const strings = _global.strings;
-const MutableString = _global.MutableString;
-const stringZ = _global.stringZ;
-const default_allocator = _global.default_allocator;
-const C = _global.C;
+const bun = @import("../global.zig");
+const string = bun.string;
+const Output = bun.Output;
+const Global = bun.Global;
+const Environment = bun.Environment;
+const strings = bun.strings;
+const MutableString = bun.MutableString;
+const stringZ = bun.stringZ;
+const default_allocator = bun.default_allocator;
+const C = bun.C;
const std = @import("std");
/// String type that stores either an offset/length into an external buffer or a string inline directly