aboutsummaryrefslogtreecommitdiff
path: root/src/install
diff options
context:
space:
mode:
Diffstat (limited to 'src/install')
-rw-r--r--src/install/dependency.zig7
-rw-r--r--src/install/install.zig5
-rw-r--r--src/install/lockfile.zig24
-rw-r--r--src/install/repository.zig20
4 files changed, 48 insertions, 8 deletions
diff --git a/src/install/dependency.zig b/src/install/dependency.zig
index cb73c04e1..c070a368b 100644
--- a/src/install/dependency.zig
+++ b/src/install/dependency.zig
@@ -13,6 +13,7 @@ const String = Semver.String;
const std = @import("std");
const string = @import("../string_types.zig").string;
const strings = @import("../string_immutable.zig");
+const PackageManager = @import("./install.zig").PackageManager;
const Dependency = @This();
const URI = union(Tag) {
@@ -686,7 +687,11 @@ pub fn parseWithOptionalTag(
allocator,
alias,
dep,
- tag orelse Version.Tag.infer(dep),
+ tag orelse brk: {
+ const t = Version.Tag.infer(dep);
+ if (t == .github) break :brk if (PackageManager.instance.options.use_github_api) .github else .git;
+ break :brk t;
+ },
sliced,
log,
);
diff --git a/src/install/install.zig b/src/install/install.zig
index abac43493..07d433f3d 100644
--- a/src/install/install.zig
+++ b/src/install/install.zig
@@ -4545,6 +4545,8 @@ pub const PackageManager = struct {
max_retry_count: u16 = 5,
min_simultaneous_requests: usize = 4,
+ use_github_api: bool = true,
+
pub fn shouldPrintCommandName(this: *const Options) bool {
return this.log_level != .silent and this.do.summary;
}
@@ -4675,6 +4677,9 @@ pub const PackageManager = struct {
if (bun_install.default_registry) |registry| {
base = registry;
}
+ if (bun_install.use_github_api) |use_github_api| {
+ this.use_github_api = use_github_api;
+ }
}
if (base.url.len == 0) base.url = Npm.Registry.default_url;
this.scope = try Npm.Registry.Scope.fromAPI("", base, allocator, env);
diff --git a/src/install/lockfile.zig b/src/install/lockfile.zig
index dc0a64475..76f6fedc7 100644
--- a/src/install/lockfile.zig
+++ b/src/install/lockfile.zig
@@ -1505,13 +1505,23 @@ pub fn verifyResolutions(this: *Lockfile, local_features: Features, remote_featu
},
);
} else {
- Output.prettyErrorln(
- "<r><red>error<r><d>:<r> <b>{s}<r><d>@<b>{}<r><d> failed to resolve<r>\n",
- .{
- failed_dep.name.slice(string_buf),
- failed_dep.version.literal.fmt(string_buf),
- },
- );
+ if (failed_dep.version.tag == .github) {
+ Output.prettyErrorln(
+ "<r><red>error<r><d>:<r> <b>{s}<r><d>@<b>{}<r><d> failed to resolve<r>\nIf this is a private repository set install.github.api to false in bunfig.toml\n\n",
+ .{
+ failed_dep.name.slice(string_buf),
+ failed_dep.version.literal.fmt(string_buf),
+ },
+ );
+ } else {
+ Output.prettyErrorln(
+ "<r><red>error<r><d>:<r> <b>{s}<r><d>@<b>{}<r><d> failed to resolve<r>\n",
+ .{
+ failed_dep.name.slice(string_buf),
+ failed_dep.version.literal.fmt(string_buf),
+ },
+ );
+ }
}
}
// track this so we can log each failure instead of just the first
diff --git a/src/install/repository.zig b/src/install/repository.zig
index 17afec079..6dcdc2646 100644
--- a/src/install/repository.zig
+++ b/src/install/repository.zig
@@ -156,6 +156,26 @@ pub const Repository = extern struct {
return final_path_buf[0 .. url.len + "https://".len];
}
+ {
+ var i: usize = 0;
+ while (i < url.len) {
+ switch (url[i]) {
+ '/' => {
+ if (i < url.len - 1) {
+ // username/repo-name
+ final_path_buf[0.."https://github.com/".len].* = "https://github.com/".*;
+ bun.copy(u8, final_path_buf["https://github.com/".len..], url);
+ return final_path_buf[0 .. url.len + "https://github.com/".len];
+ }
+ },
+ '@', ':', '+' => return null,
+ else => {},
+ }
+
+ i += 1;
+ }
+ }
+
return null;
}