mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 10:58:56 +00:00
implement pnpm migration (#22262)
### What does this PR do? fixes #7157, fixes #14662 migrates pnpm-workspace.yaml data to package.json & converts pnpm-lock.yml to bun.lock --- ### How did you verify your code works? manually, tests and real world examples --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
This commit is contained in:
@@ -111,17 +111,6 @@ pub const UpdateInteractiveCommand = struct {
|
||||
};
|
||||
}
|
||||
|
||||
fn resolveCatalogDependency(manager: *PackageManager, dep: Install.Dependency) ?Install.Dependency.Version {
|
||||
return if (dep.version.tag == .catalog) blk: {
|
||||
const catalog_dep = manager.lockfile.catalogs.get(
|
||||
manager.lockfile,
|
||||
dep.version.value.catalog,
|
||||
dep.name,
|
||||
) orelse return null;
|
||||
break :blk catalog_dep.version;
|
||||
} else dep.version;
|
||||
}
|
||||
|
||||
pub fn exec(ctx: Command.Context) !void {
|
||||
Output.prettyln("<r><b>bun update --interactive <r><d>v" ++ Global.package_json_version_with_sha ++ "<r>", .{});
|
||||
Output.flush();
|
||||
@@ -383,7 +372,7 @@ pub const UpdateInteractiveCommand = struct {
|
||||
};
|
||||
defer bun.default_allocator.free(workspace_pkg_ids);
|
||||
|
||||
try OutdatedCommand.updateManifestsIfNecessary(manager, workspace_pkg_ids);
|
||||
try manager.populateManifestCache(.{ .ids = workspace_pkg_ids });
|
||||
|
||||
// Get outdated packages
|
||||
const outdated_packages = try getOutdatedPackages(bun.default_allocator, manager, workspace_pkg_ids);
|
||||
@@ -531,21 +520,13 @@ pub const UpdateInteractiveCommand = struct {
|
||||
try updatePackageJsonFilesFromUpdates(manager, package_updates.items);
|
||||
}
|
||||
|
||||
// Get the root package.json from cache (should be updated after our saves)
|
||||
const package_json_contents = manager.root_package_json_file.readToEndAlloc(ctx.allocator, std.math.maxInt(usize)) catch |err| {
|
||||
if (manager.options.log_level != .silent) {
|
||||
Output.prettyErrorln("<r><red>{s} reading package.json<r> :(", .{@errorName(err)});
|
||||
Output.flush();
|
||||
}
|
||||
return;
|
||||
};
|
||||
manager.to_update = true;
|
||||
|
||||
// Reset the timer to show actual install time instead of total command time
|
||||
var install_ctx = ctx;
|
||||
install_ctx.start_time = std.time.nanoTimestamp();
|
||||
|
||||
try PackageManager.installWithManager(manager, install_ctx, package_json_contents, manager.root_dir.dir);
|
||||
try PackageManager.installWithManager(manager, install_ctx, PackageManager.root_package_json_path, manager.root_dir.dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -752,8 +733,8 @@ pub const UpdateInteractiveCommand = struct {
|
||||
for (pkg_deps.begin()..pkg_deps.end()) |dep_id| {
|
||||
const package_id = lockfile.buffers.resolutions.items[dep_id];
|
||||
if (package_id == invalid_package_id) continue;
|
||||
const dep = lockfile.buffers.dependencies.items[dep_id];
|
||||
const resolved_version = resolveCatalogDependency(manager, dep) orelse continue;
|
||||
const dep = &lockfile.buffers.dependencies.items[dep_id];
|
||||
const resolved_version = manager.lockfile.resolveCatalogDependency(dep) orelse continue;
|
||||
if (resolved_version.tag != .npm and resolved_version.tag != .dist_tag) continue;
|
||||
const resolution = pkg_resolutions[package_id];
|
||||
if (resolution.tag != .npm) continue;
|
||||
@@ -2016,6 +1997,7 @@ const glob = bun.glob;
|
||||
const logger = bun.logger;
|
||||
const path = bun.path;
|
||||
const strings = bun.strings;
|
||||
const Command = bun.cli.Command;
|
||||
const FileSystem = bun.fs.FileSystem;
|
||||
|
||||
const Semver = bun.Semver;
|
||||
@@ -2026,9 +2008,6 @@ const JSAst = bun.ast;
|
||||
const E = JSAst.E;
|
||||
const Expr = JSAst.Expr;
|
||||
|
||||
const Command = bun.cli.Command;
|
||||
const OutdatedCommand = bun.cli.OutdatedCommand;
|
||||
|
||||
const Install = bun.install;
|
||||
const DependencyID = Install.DependencyID;
|
||||
const PackageID = Install.PackageID;
|
||||
|
||||
Reference in New Issue
Block a user