mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 05:12:29 +00:00
feat(install): automatically migrate package-lock.json to bun.lockb (#6352)
* work so far * stuff * a * basics work * stuff * yoo * build lockfile * correct * f * a * install fixture havent tested * i made it worse * lol * be more reasonable * make the test easier to pass because bun install doesn't handle obscure lockfile edge cases :/ * a * works now * ok * a * a * cool * nah * fix stuff * l * a * idfk * LAME * prettier errors * does this fix tests? * Add more safety checks to Integrity * Add another check * More careful lifetime handling * Fix linux debugger issue * a * tmp dir and snapshot test --------- Co-authored-by: Jarred SUmner <jarred@jarredsumner.com>
This commit is contained in:
@@ -243,6 +243,32 @@ pub const PackageManagerCommand = struct {
|
||||
}
|
||||
}
|
||||
|
||||
Global.exit(0);
|
||||
} else if (strings.eqlComptime(subcommand, "migrate")) {
|
||||
if (!pm.options.enable.force_save_lockfile) try_load_bun: {
|
||||
std.fs.cwd().accessZ("bun.lockb", .{ .mode = .read_only }) catch break :try_load_bun;
|
||||
|
||||
Output.prettyErrorln(
|
||||
\\<r><red>error<r>: bun.lockb already exists
|
||||
\\run with --force to overwrite
|
||||
, .{});
|
||||
Global.exit(1);
|
||||
}
|
||||
const load_lockfile = @import("../install/migration.zig").detectAndLoadOtherLockfile(
|
||||
pm.lockfile,
|
||||
ctx.allocator,
|
||||
pm.log,
|
||||
pm.options.lockfile_path,
|
||||
);
|
||||
if (load_lockfile == .not_found) {
|
||||
Output.prettyErrorln(
|
||||
\\<r><red>error<r>: could not find any other lockfile
|
||||
, .{});
|
||||
Global.exit(1);
|
||||
}
|
||||
handleLoadLockfileErrors(load_lockfile, pm);
|
||||
const lockfile = load_lockfile.ok;
|
||||
lockfile.saveToDisk(pm.options.lockfile_path);
|
||||
Global.exit(0);
|
||||
}
|
||||
|
||||
@@ -258,6 +284,7 @@ pub const PackageManagerCommand = struct {
|
||||
\\ bun pm <b>hash-print<r> print the hash stored in the current lockfile
|
||||
\\ bun pm <b>cache<r> print the path to the cache folder
|
||||
\\ bun pm <b>cache rm<r> clear the cache
|
||||
\\ bun pm <b>migrate<r> migrate another package manager's lockfile without installing anything
|
||||
\\
|
||||
\\Learn more about these at <magenta>https://bun.sh/docs/install/utilities<r>
|
||||
\\
|
||||
|
||||
Reference in New Issue
Block a user