Compare commits

...

1 Commits

Author SHA1 Message Date
Jarred Sumner
5fb6e5ce87 wip 2025-02-27 06:42:03 -08:00
3 changed files with 1688 additions and 1 deletions

View File

@@ -108,6 +108,7 @@ pub const Features = struct {
pub var lifecycle_scripts: usize = 0;
pub var loaders: usize = 0;
pub var lockfile_migration_from_package_lock: usize = 0;
pub var lockfile_migration_from_pnpm_lock: usize = 0;
pub var text_lockfile: usize = 0;
pub var macros: usize = 0;
pub var no_avx2: usize = 0;

File diff suppressed because it is too large Load Diff

View File

@@ -37,6 +37,8 @@ const S = JSAst.S;
const debug = Output.scoped(.migrate, false);
const migration_pnpm = @import("./migration.pnpm.zig");
pub fn detectAndLoadOtherLockfile(
this: *Lockfile,
dir: bun.FD,
@@ -44,7 +46,7 @@ pub fn detectAndLoadOtherLockfile(
allocator: Allocator,
log: *logger.Log,
) LoadResult {
// check for package-lock.json, yarn.lock, etc...
// check for package-lock.json, pnpm-lock.yaml, etc...
// if it exists, do an in-memory migration
npm: {
@@ -89,6 +91,44 @@ pub fn detectAndLoadOtherLockfile(
return migrate_result;
}
pnpm: {
var timer = std.time.Timer.start() catch unreachable;
const lockfile = File.openat(dir, "pnpm-lock.yaml", bun.O.RDONLY, 0).unwrap() catch break :pnpm;
defer lockfile.close();
var lockfile_path_buf: bun.PathBuffer = undefined;
const lockfile_path = bun.getFdPathZ(lockfile.handle, &lockfile_path_buf) catch break :pnpm;
const data = lockfile.readToEnd(allocator).unwrap() catch break :pnpm;
const migrate_result = migration_pnpm.migratePNPMLockfile(this, manager, allocator, log, data, lockfile_path) catch |err| {
if (err == error.UnsupportedPNPMLockfileVersion) {
log.print(Output.errorWriter()) catch {};
Global.exit(1);
}
if (Environment.isDebug) {
bun.handleErrorReturnTrace(err, @errorReturnTrace());
Output.prettyErrorln("Error: {s}", .{@errorName(err)});
log.print(Output.errorWriter()) catch {};
Output.prettyErrorln("Invalid PNPM pnpm-lock.yaml\nIn a release build, this would ignore and do a fresh install.\nAborting", .{});
Global.exit(1);
}
return LoadResult{ .err = .{
.step = .migrating,
.value = err,
.lockfile_path = "pnpm-lock.yaml",
.format = .binary,
} };
};
if (migrate_result == .ok) {
Output.printElapsed(@as(f64, @floatFromInt(timer.read())) / std.time.ns_per_ms);
Output.prettyError(" ", .{});
Output.prettyErrorln("<d>migrated lockfile from <r><green>pnpm-lock.yaml<r>", .{});
Output.flush();
}
return migrate_result;
}
return LoadResult{ .not_found = {} };
}