Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# commit-tools

[![Version](https://img.shields.io/badge/version-0.2.5-blue.svg)](#)
[![Version](https://img.shields.io/badge/version-0.2.6-blue.svg)](#)

Writing good commit messages _can_ have a high cognitive cost, especially when you make dozens of commits a day. That energy should be directed toward solving hard problems and shipping features, not summarizing them.

Expand Down Expand Up @@ -142,6 +142,24 @@ Verify your installation, environment, and configuration:
commit doctor
```

### Stay Up to Date

`commit-tools` checks the npm registry once per day and shows a banner when a newer version is available. To install the latest release, run:

```bash
commit update
```

The command auto-detects your global package manager (npm, pnpm, or Yarn 1). Modern Yarn (≥ 2) does not support global installs — use npm or pnpm instead.

To silence the update banner (e.g. for CI or scripted environments), set:

```bash
NO_UPDATE_NOTIFIER=true
```

The banner is also suppressed automatically in non-interactive shells and when `CI=true`.

## Commands

To see all available commands at any time, run:
Expand All @@ -159,6 +177,7 @@ commit --help
| `commit doctor` | Check installation and environment |
| `commit model` | Select a different AI model |
| `commit effort` | Adjust the reasoning effort for the current model |
| `commit update` | Install the latest version from npm |
| `commit --version`, `-v` | Show version |
| `commit --help`, `-h` | Show help |

Expand Down
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Update } from "@/cli/update";
import { type CliCommand, parseArgs, showHelp, showVersion } from "@/cli/parser";
import { Future } from "@/libs/future";
import { absurd } from "@/libs/types";
import { checkUpdate } from "@/cli/show-update-banner";
import { checkUpdate } from "@/cli/update";

import color from "picocolors";

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rafaeelricco/commit-tools",
"version": "0.2.6",
"version": "0.2.7",
"type": "module",
"bin": {
"commit": "./dist/index.js"
Expand Down
6 changes: 3 additions & 3 deletions src/cli/commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ class Commit {

if (p.isCancel(action) || action === "cancel") {
p.outro("Operation cancelled.");
return "cancel" as UserAction;
return "cancel";
}

return action as UserAction;
return action;
});
}

Expand Down Expand Up @@ -202,7 +202,7 @@ class Commit {
message: "What adjustments would you like?",
placeholder: "e.g. make it more concise"
});
return p.isCancel(adj) ? Nothing<string>() : Just(adj as string);
return p.isCancel(adj) ? Nothing<string>() : Just(adj);
});
}
}
19 changes: 0 additions & 19 deletions src/cli/show-update-banner.ts

This file was deleted.

22 changes: 20 additions & 2 deletions src/cli/update.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
export { Update };
export { Update, checkUpdate };

import * as p from "@clack/prompts";
import color from "picocolors";

import { checkForUpdate, compareVersions } from "@/infra/version-check";
import { renderUpdateBanner } from "@/infra/ui/update-banner";
import { version } from "@/package.json";
import { Future } from "@/libs/future";
import { execBin, execBinInteractive } from "@/infra/shell";

import color from "picocolors";

const PACKAGE_NAME = "@rafaeelricco/commit-tools";

type PackageManager = { name: "pnpm" | "yarn" | "npm"; cmd: string; args: string[] };
Expand Down Expand Up @@ -80,3 +84,17 @@ class Update {
});
}
}

const isOptedOut = (): boolean => process.env["NO_UPDATE_NOTIFIER"] === "true";
const isCi = (): boolean => Boolean(process.env["CI"]);
const isNonInteractive = (): boolean => !process.stdout.isTTY;

const shouldSuppress = (): boolean => isOptedOut() || isCi() || isNonInteractive();

const checkUpdate = (): void => {
if (shouldSuppress()) return;
const current = version;
checkForUpdate().maybe(undefined, (latest) => {
if (compareVersions(latest, current) > 0) renderUpdateBanner({ current, latest });
});
};