mirror of
https://github.com/oven-sh/bun
synced 2026-02-18 14:51:52 +00:00
fix(outdated): show catalog info without requiring --filter or -r (#23039)
## Summary
The `bun outdated` command now displays catalog dependencies with their
workspace grouping even when run without the `--filter` or `-r` flags.
## What changed
- Added detection for catalog dependencies in the outdated packages list
- The workspace column is now shown when:
- Using `--filter` or `-r` flags (existing behavior)
- OR when there are catalog dependencies to display (new behavior)
- When there are no catalog dependencies and no filtering, the workspace
column remains hidden as before
## Why
Previously, running `bun outdated` without any flags would not show
which workspaces were using catalog dependencies, making it unclear
where catalog entries were being used. This fix ensures catalog
dependencies are properly grouped and displayed with their workspace
information.
## Test
```bash
# Create a workspace project with catalog dependencies
mkdir test-catalog && cd test-catalog
cat > package.json << 'JSON'
{
"name": "test-catalog",
"workspaces": ["packages/*"],
"catalog": {
"react": "^17.0.0"
}
}
JSON
mkdir -p packages/{app1,app2}
echo '{"name":"app1","dependencies":{"react":"catalog:"}}' > packages/app1/package.json
echo '{"name":"app2","dependencies":{"react":"catalog:"}}' > packages/app2/package.json
bun install
bun outdated # Should now show catalog grouping without needing --filter
```
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
This commit is contained in:
@@ -484,12 +484,17 @@ pub const OutdatedCommand = struct {
|
||||
|
||||
// Recalculate max workspace length after grouping
|
||||
var new_max_workspace: usize = max_workspace;
|
||||
var has_catalog_deps = false;
|
||||
for (grouped_ids.items) |item| {
|
||||
if (item.grouped_workspace_names) |names| {
|
||||
if (names.len > new_max_workspace) new_max_workspace = names.len;
|
||||
has_catalog_deps = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Show workspace column if filtered OR if there are catalog dependencies
|
||||
const show_workspace_column = was_filtered or has_catalog_deps;
|
||||
|
||||
const package_column_inside_length = @max("Packages".len, max_name);
|
||||
const current_column_inside_length = @max("Current".len, max_current);
|
||||
const update_column_inside_length = @max("Update".len, max_update);
|
||||
@@ -500,7 +505,7 @@ pub const OutdatedCommand = struct {
|
||||
const column_right_pad = 1;
|
||||
|
||||
const table = Table("blue", column_left_pad, column_right_pad, enable_ansi_colors).init(
|
||||
&if (was_filtered)
|
||||
&if (show_workspace_column)
|
||||
[_][]const u8{
|
||||
"Package",
|
||||
"Current",
|
||||
@@ -515,7 +520,7 @@ pub const OutdatedCommand = struct {
|
||||
"Update",
|
||||
"Latest",
|
||||
},
|
||||
&if (was_filtered)
|
||||
&if (show_workspace_column)
|
||||
[_]usize{
|
||||
package_column_inside_length,
|
||||
current_column_inside_length,
|
||||
@@ -621,7 +626,7 @@ pub const OutdatedCommand = struct {
|
||||
version_buf.clearRetainingCapacity();
|
||||
}
|
||||
|
||||
if (was_filtered) {
|
||||
if (show_workspace_column) {
|
||||
Output.pretty("{s}", .{table.symbols.verticalEdge()});
|
||||
for (0..column_left_pad) |_| Output.pretty(" ", .{});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user