mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 20:39:05 +00:00
### What does this PR do? Sometimes packages will use very large numbers exceeding max u32 for major/minor/patch (usually patch). This pr changes each core number in bun to u64. Because we serialize package information to disk for the binary lockfile and package manifests, this pr bumps the version of each. We don't need to change anything other than the version for serialized package manifests because they will invalidate and save the new version. For old binary lockfiles, this pr adds logic for migrating to the new version. Even if there are no changes, migrating will always save the new lockfile. Unfortunately means there will be a one time invisible diff for binary lockfile users, but this is better than installs failing to work. fixes #22881 fixes #21793 fixes #16041 fixes #22891 resolves BUN-7MX, BUN-R4Q, BUN-WRB ### How did you verify your code works? Manually, and added a test for migrating from an older binary lockfile. --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
45 lines
1.5 KiB
Zig
45 lines
1.5 KiB
Zig
pub const VersionedURL = VersionedURLType(u64);
|
|
pub const OldV2VersionedURL = VersionedURLType(u32);
|
|
|
|
pub fn VersionedURLType(comptime SemverIntType: type) type {
|
|
return extern struct {
|
|
url: String,
|
|
version: Semver.VersionType(SemverIntType),
|
|
|
|
pub fn eql(this: @This(), other: @This()) bool {
|
|
return this.version.eql(other.version);
|
|
}
|
|
|
|
pub fn order(this: @This(), other: @This(), lhs_buf: []const u8, rhs_buf: []const u8) @import("std").math.Order {
|
|
return this.version.order(other.version, lhs_buf, rhs_buf);
|
|
}
|
|
|
|
pub fn count(this: @This(), buf: []const u8, comptime Builder: type, builder: Builder) void {
|
|
this.version.count(buf, comptime Builder, builder);
|
|
builder.count(this.url.slice(buf));
|
|
}
|
|
|
|
pub fn clone(this: @This(), buf: []const u8, comptime Builder: type, builder: Builder) @This() {
|
|
return @This(){
|
|
.version = this.version.append(buf, Builder, builder),
|
|
.url = builder.append(String, this.url.slice(buf)),
|
|
};
|
|
}
|
|
|
|
pub fn migrate(this: @This()) VersionedURLType(u64) {
|
|
if (comptime SemverIntType != u32) {
|
|
@compileError("unexpected SemverIntType");
|
|
}
|
|
return .{
|
|
.url = this.url,
|
|
.version = this.version.migrate(),
|
|
};
|
|
}
|
|
};
|
|
}
|
|
|
|
const bun = @import("bun");
|
|
|
|
const Semver = bun.Semver;
|
|
const String = Semver.String;
|