diff --git a/src/install/migration.zig b/src/install/migration.zig index 2390d4e850d5..fcf417b140ec 100644 --- a/src/install/migration.zig +++ b/src/install/migration.zig @@ -26,14 +26,6 @@ pub fn detectAndLoadOtherLockfile( , .{}); Global.exit(1); } - if (Environment.isDebug) { - bun.handleErrorReturnTrace(err, @errorReturnTrace()); - - Output.prettyErrorln("Error: {s}", .{@errorName(err)}); - log.print(Output.errorWriter()) catch {}; - Output.prettyErrorln("Invalid NPM package-lock.json\nIn a release build, this would ignore and do a fresh install.\nAborting", .{}); - Global.exit(1); - } return LoadResult{ .err = .{ .step = .migrating, .value = err, @@ -58,14 +50,6 @@ pub fn detectAndLoadOtherLockfile( defer lockfile.close(); const data = lockfile.readToEnd(allocator).unwrap() catch break :yarn; const migrate_result = @import("./yarn.zig").migrateYarnLockfile(this, manager, allocator, log, data, dir) catch |err| { - if (Environment.isDebug) { - bun.handleErrorReturnTrace(err, @errorReturnTrace()); - - Output.prettyErrorln("Error: {s}", .{@errorName(err)}); - log.print(Output.errorWriter()) catch {}; - Output.prettyErrorln("Invalid yarn.lock\nIn a release build, this would ignore and do a fresh install.\nAborting", .{}); - Global.exit(1); - } return LoadResult{ .err = .{ .step = .migrating, .value = err, @@ -137,14 +121,7 @@ pub fn detectAndLoadOtherLockfile( }, else => {}, } - if (Environment.isDebug) { - bun.handleErrorReturnTrace(err, @errorReturnTrace()); - - Output.prettyErrorln("Error: {s}", .{@errorName(err)}); - log.print(Output.errorWriter()) catch {}; - Output.prettyErrorln("Invalid pnpm-lock.yaml\nIn a release build, this would ignore and do a fresh install.\nAborting", .{}); - Global.exit(1); - } + log.reset(); return LoadResult{ .err = .{ .step = .migrating, .value = err, diff --git a/src/install/pnpm.zig b/src/install/pnpm.zig index eb7e7596391d..33e733a6ad1f 100644 --- a/src/install/pnpm.zig +++ b/src/install/pnpm.zig @@ -105,21 +105,21 @@ pub fn migratePnpmLockfile( return error.PnpmLockfileMissingVersion; }; - const lockfile_version_num: u32 = lockfile_version: { + const lockfile_version_num: f64 = lockfile_version: { err: { switch (lockfile_version_expr.data) { .e_number => |num| { - if (num.value < 0 or num.value > std.math.maxInt(u32)) { + if (num.value < 0) { break :err; } - break :lockfile_version @intFromFloat(std.math.divExact(f64, num.value, 1) catch break :err); + break :lockfile_version num.value; }, .e_string => |version_str| { const str = version_str.slice(allocator); const end = strings.indexOfChar(str, '.') orelse str.len; - break :lockfile_version std.fmt.parseUnsigned(u32, str[0..end], 10) catch break :err; + break :lockfile_version std.fmt.parseFloat(f64, str[0..end]) catch break :err; }, else => {}, } diff --git a/test/cli/install/migration/pnpm-migration.test.ts b/test/cli/install/migration/pnpm-migration.test.ts index 5ce3d4219e8b..d92a68ad23e6 100644 --- a/test/cli/install/migration/pnpm-migration.test.ts +++ b/test/cli/install/migration/pnpm-migration.test.ts @@ -54,6 +54,25 @@ test("basic", async () => { expect(err).not.toContain("Saved lockfile"); }); +test("version is number with dot", async () => { + const { packageDir } = await verdaccio.createTestDir({ + files: join(import.meta.dir, "pnpm/version-number-dot"), + }); + + let proc = spawn({ + cmd: [bunExe(), "install"], + cwd: packageDir, + env, + stdout: "pipe", + stderr: "pipe", + }); + + let [err, exitCode] = await Promise.all([proc.stderr.text(), proc.exited]); + + expect(exitCode).toBe(0); + expect(err).toContain("pnpm-lock.yaml version is too old (< v7)"); +}); + describe.todo("bin", () => { test("manifests are fetched for bins", async () => { const { packageDir, packageJson } = await verdaccio.createTestDir({ diff --git a/test/cli/install/migration/pnpm/version-number-dot/package.json b/test/cli/install/migration/pnpm/version-number-dot/package.json new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/cli/install/migration/pnpm/version-number-dot/pnpm-lock.yaml b/test/cli/install/migration/pnpm/version-number-dot/pnpm-lock.yaml new file mode 100644 index 000000000000..9764deb1cccc --- /dev/null +++ b/test/cli/install/migration/pnpm/version-number-dot/pnpm-lock.yaml @@ -0,0 +1 @@ +lockfileVersion: 5.4