aboutsummaryrefslogtreecommitdiff
path: root/src/cli
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/bunx_command.zig24
-rw-r--r--src/cli/package_manager_command.zig27
2 files changed, 40 insertions, 11 deletions
diff --git a/src/cli/bunx_command.zig b/src/cli/bunx_command.zig
index dba2d5664..e7f35d10d 100644
--- a/src/cli/bunx_command.zig
+++ b/src/cli/bunx_command.zig
@@ -236,6 +236,8 @@ pub const BunxCommand = struct {
const initial_bin_name = if (strings.eqlComptime(update_request.name, "typescript"))
"tsc"
+ else if (update_request.version.tag == .github)
+ update_request.version.value.github.repo.slice(update_request.version_buf)
else if (strings.lastIndexOfChar(update_request.name, '/')) |index|
update_request.name[index + 1 ..]
else
@@ -262,19 +264,19 @@ pub const BunxCommand = struct {
else
update_request.version.literal.slice(update_request.version_buf);
- const package_fmt: []const u8 = brk: {
- if (!strings.eql(update_request.version_buf, update_request.name)) {
- break :brk try std.fmt.allocPrint(
- ctx.allocator,
- "{s}@{s}",
- .{
- update_request.name,
- display_version,
- },
- );
+ const package_fmt = brk: {
+ if (update_request.version.tag == .github) {
+ break :brk update_request.version.literal.slice(update_request.version_buf);
}
- break :brk update_request.name;
+ break :brk try std.fmt.allocPrint(
+ ctx.allocator,
+ "{s}@{s}",
+ .{
+ update_request.name,
+ display_version,
+ },
+ );
};
const PATH_FOR_BIN_DIRS = PATH;
diff --git a/src/cli/package_manager_command.zig b/src/cli/package_manager_command.zig
index aef7c28a9..00326bc97 100644
--- a/src/cli/package_manager_command.zig
+++ b/src/cli/package_manager_command.zig
@@ -244,6 +244,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);
}
Output.prettyln(
@@ -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>
\\