Skip to content

Commit

Permalink
bun outdated docs (#13497)
Browse files Browse the repository at this point in the history
Co-authored-by: Zack Radisic <[email protected]>
  • Loading branch information
dylan-conway and zackradisic authored Aug 24, 2024
1 parent b005ef4 commit 1a9307d
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 20 deletions.
2 changes: 1 addition & 1 deletion completions/bun.bash
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ _bun_completions() {
declare -A PACKAGE_OPTIONS;
declare -A PM_OPTIONS;

local SUBCOMMANDS="dev bun create run install add remove upgrade completions discord help init pm x test repl update link unlink build";
local SUBCOMMANDS="dev bun create run install add remove upgrade completions discord help init pm x test repl update outdated link unlink build";

GLOBAL_OPTIONS[LONG_OPTIONS]="--use --cwd --bunfile --server-bunfile --config --disable-react-fast-refresh --disable-hmr --env-file --extension-order --jsx-factory --jsx-fragment --extension-order --jsx-factory --jsx-fragment --jsx-import-source --jsx-production --jsx-runtime --main-fields --no-summary --version --platform --public-dir --tsconfig-override --define --external --help --inject --loader --origin --port --dump-environment-variables --dump-limits --disable-bun-js";
GLOBAL_OPTIONS[SHORT_OPTIONS]="-c -v -d -e -h -i -l -u -p";
Expand Down
3 changes: 2 additions & 1 deletion completions/bun.fish
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ complete -c bun -n "__fish_use_subcommand" -a "remove" -d "Remove a dependency f
complete -c bun -n "__fish_use_subcommand" -a "add" -d "Add a dependency to package.json" -f
complete -c bun -n "__fish_use_subcommand" -a "init" -d "Initialize a Bun project in this directory" -f
complete -c bun -n "__fish_use_subcommand" -a "link" -d "Register or link a local npm package" -f
complete -c bun -n "__fish_use_subcommand" -a "link" -d "Unregister a local npm package" -f
complete -c bun -n "__fish_use_subcommand" -a "unlink" -d "Unregister a local npm package" -f
complete -c bun -n "__fish_use_subcommand" -a "pm" -d "Additional package management utilities" -f
complete -c bun -n "__fish_use_subcommand" -a "x" -d "Execute a package binary, installing if needed" -f
complete -c bun -n "__fish_use_subcommand" -a "outdated" -d "Display the latest versions of outdated dependencies" -f
25 changes: 25 additions & 0 deletions completions/bun.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,22 @@ _bun_update_completion() {
esac
}

_bun_outdated_completion() {
_arguments -s -C \
'--cwd[Set a specific cwd]:cwd' \
'--verbose[Excessively verbose logging]' \
'--no-progress[Disable the progress bar]' \
'--help[Print this help menu]' &&
ret=0

case $state in
config)
_bun_list_bunfig_toml

;;
esac
}

_bun_test_completion() {
_arguments -s -C \
'1: :->cmd1' \
Expand Down Expand Up @@ -669,6 +685,7 @@ _bun() {
'add\:"Add a dependency to package.json (bun a)" '
'remove\:"Remove a dependency from package.json (bun rm)" '
'update\:"Update outdated dependencies & save to package.json" '
'outdated\:"Display the latest versions of outdated dependencies" '
'link\:"Link an npm package globally" '
'unlink\:"Globally unlink an npm package" '
'pm\:"More commands for managing packages" '
Expand Down Expand Up @@ -740,6 +757,10 @@ _bun() {
update)
_bun_update_completion

;;
outdated)
_bun_outdated_completion

;;
'test')
_bun_test_completion
Expand Down Expand Up @@ -819,6 +840,10 @@ _bun() {
update)
_bun_update_completion

;;
outdated)
_bun_outdated_completion

;;
'test')
_bun_test_completion
Expand Down
27 changes: 27 additions & 0 deletions docs/cli/outdated.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Use `bun outdated` to display a table of outdated dependencies with their latest versions:

```sh
$ bun outdated

|--------------------------------------------------------------------|
| Packages | Current | Update | Latest |
|----------------------------------------|---------|--------|--------|
| @types/bun (dev) | 1.1.6 | 1.1.7 | 1.1.7 |
|----------------------------------------|---------|--------|--------|
| @types/react (dev) | 18.3.3 | 18.3.4 | 18.3.4 |
|----------------------------------------|---------|--------|--------|
| @typescript-eslint/eslint-plugin (dev) | 7.16.1 | 7.18.0 | 8.2.0 |
|----------------------------------------|---------|--------|--------|
| @typescript-eslint/parser (dev) | 7.16.1 | 7.18.0 | 8.2.0 |
|----------------------------------------|---------|--------|--------|
| esbuild (dev) | 0.21.5 | 0.21.5 | 0.23.1 |
|----------------------------------------|---------|--------|--------|
| eslint (dev) | 9.7.0 | 9.9.1 | 9.9.1 |
|----------------------------------------|---------|--------|--------|
| typescript (dev) | 5.5.3 | 5.5.4 | 5.5.4 |
|--------------------------------------------------------------------|
```

The `Update` column shows the version that would be installed if you ran `bun update [package]`. This version is the latest version that satisfies the version range specified in your `package.json`.

The `Latest` column shows the latest version available from the registry. `bun update --latest [package]` will update to this version.
1 change: 1 addition & 0 deletions src/cli.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,7 @@ pub const HelpCommand = struct {
\\ <b><blue>add<r> <d>{s:<16}<r> Add a dependency to package.json <d>(bun a)<r>
\\ <b><blue>remove<r> <d>{s:<16}<r> Remove a dependency from package.json <d>(bun rm)<r>
\\ <b><blue>update<r> <d>{s:<16}<r> Update outdated dependencies
\\ <b><blue>outdated<r> Display latest versions of outdated dependencies
\\ <b><blue>link<r> <d>[\<package\>]<r> Register or link a local npm package
\\ <b><blue>unlink<r> Unregister a local npm package
\\ <b><blue>patch <d>\<pkg\><r> Prepare a package for patching
Expand Down
6 changes: 3 additions & 3 deletions src/cli/outdated_command.zig
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ fn Table(

pub const OutdatedCommand = struct {
pub fn exec(ctx: Command.Context) !void {
Output.prettyErrorln("<r><b>bun outdated <r><d>v" ++ Global.package_json_version_with_sha ++ "<r>", .{});
Output.flush();

const cli = try PackageManager.CommandLineArguments.parse(ctx.allocator, .outdated);

const manager = PackageManager.init(ctx, cli, .outdated) catch |err| {
Expand Down Expand Up @@ -183,9 +186,6 @@ pub const OutdatedCommand = struct {
if (root_pkg_id == invalid_package_id) return;
const root_pkg_deps = lockfile.packages.items(.dependencies)[root_pkg_id];

Output.prettyErrorln("<r><b>bun outdated <r><d>v" ++ Global.package_json_version_with_sha ++ "<r>", .{});
Output.flush();

try updateManifestsIfNecessary(manager, log_level, root_pkg_deps);

try switch (Output.enable_ansi_colors) {
Expand Down
4 changes: 2 additions & 2 deletions src/install/semver.zig
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ pub const Version = extern struct {
const diff = this.version.whichVersionIsDifferent(this.other, this.buf, this.other_buf) orelse .none;

switch (diff) {
.major => try writer.print(Output.prettyFmt("<b><red>{d}.{d}.{d}", true), .{
.major => try writer.print(Output.prettyFmt("<r><b><red>{d}.{d}.{d}", true), .{
this.version.major, this.version.minor, this.version.patch,
}),
.minor => {
Expand All @@ -677,7 +677,7 @@ pub const Version = extern struct {
this.version.major, this.version.minor, this.version.patch,
});
} else {
try writer.print(Output.prettyFmt("<d>{d}.<r><yellow>{d}.{d}", true), .{
try writer.print(Output.prettyFmt("<d>{d}.<r><b><yellow>{d}.{d}", true), .{
this.version.major, this.version.minor, this.version.patch,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,11 @@ [email protected]:
"
`;

exports[`outdated NO_COLOR works 1`] = `
"|--------------------------------------|
| Packages | Current | Update | Latest |
|----------|---------|--------|--------|
| a-dep | 1.0.1 | 1.0.1 | 1.0.10 |
|--------------------------------------|
"
`;

exports[`outdated normal dep, smaller than column title 1`] = `
"┌──────────┬─────────┬────────┬────────┐
│ Packages │ Current │ Update │ Latest │
├──────────┼─────────┼────────┼────────┤
│ no-deps[2m[0m │ 1.0.0 │ [2m1.0.0[0m │ [1m[31m2.0.0[0m │
│ no-deps[2m[0m │ 1.0.0 │ [2m1.0.0[0m │ [0m[1m[31m2.0.0[0m │
└──────────┴─────────┴────────┴────────┘
"
`;
Expand All @@ -77,7 +68,7 @@ exports[`outdated dev dep, smaller than column title 1`] = `
"┌───────────────┬─────────┬────────┬────────┐
│ Packages │ Current │ Update │ Latest │
├───────────────┼─────────┼────────┼────────┤
│ no-deps[2m (dev)[0m │ 1.0.0 │ [2m1.0.0[0m │ [1m[31m2.0.0[0m │
│ no-deps[2m (dev)[0m │ 1.0.0 │ [2m1.0.0[0m │ [0m[1m[31m2.0.0[0m │
└───────────────┴─────────┴────────┴────────┘
"
`;
Expand All @@ -95,7 +86,7 @@ exports[`outdated peer dep, smaller than column title 1`] = `
"┌────────────────┬─────────┬────────┬────────┐
│ Packages │ Current │ Update │ Latest │
├────────────────┼─────────┼────────┼────────┤
│ no-deps[2m (peer)[0m │ 1.0.0 │ [2m1.0.0[0m │ [1m[31m2.0.0[0m │
│ no-deps[2m (peer)[0m │ 1.0.0 │ [2m1.0.0[0m │ [0m[1m[31m2.0.0[0m │
└────────────────┴─────────┴────────┴────────┘
"
`;
Expand All @@ -113,7 +104,7 @@ exports[`outdated optional dep, smaller than column title 1`] = `
"┌────────────────────┬─────────┬────────┬────────┐
│ Packages │ Current │ Update │ Latest │
├────────────────────┼─────────┼────────┼────────┤
│ no-deps[2m (optional)[0m │ 1.0.0 │ [2m1.0.0[0m │ [1m[31m2.0.0[0m │
│ no-deps[2m (optional)[0m │ 1.0.0 │ [2m1.0.0[0m │ [0m[1m[31m2.0.0[0m │
└────────────────────┴─────────┴────────┴────────┘
"
`;
Expand All @@ -126,3 +117,12 @@ exports[`outdated optional dep, larger than column title 1`] = `
└──────────────────────────┴────────────────┴────────────────┴────────────────┘
"
`;

exports[`outdated NO_COLOR works 1`] = `
"|--------------------------------------|
| Packages | Current | Update | Latest |
|----------|---------|--------|--------|
| a-dep | 1.0.1 | 1.0.1 | 1.0.10 |
|--------------------------------------|
"
`;

0 comments on commit 1a9307d

Please sign in to comment.