mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 05:12:29 +00:00
wip
This commit is contained in:
@@ -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;
|
||||
|
||||
1646
src/install/migration.pnpm.zig
Normal file
1646
src/install/migration.pnpm.zig
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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 = {} };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user