Skip to content

feat: add ghlt update command and update advisory banner#3

Merged
warengonzaga merged 3 commits intomainfrom
copilot/add-ghlt-update-command
Feb 24, 2026
Merged

feat: add ghlt update command and update advisory banner#3
warengonzaga merged 3 commits intomainfrom
copilot/add-ghlt-update-command

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 23, 2026

  • Explore codebase and understand structure
  • Create src/utils/updater.ts — version comparison, cache management, update check utilities
  • Create src/commands/update.tsghlt update command with --check/--dry-run flag
  • Update src/ui/banner.ts — add showUpdateBanner() function
  • Update src/index.ts — register update command and inject update advisory banner
  • Create tests/updater.test.ts — tests for version comparison logic and cache TTL behavior
  • Address PR review comments:
    • Fix redundant inner1/inner2 duplication in showUpdateBanner (banner.ts)
    • Use beforeEach/afterEach for consistent env var cleanup in updater tests
    • Fix join(cacheFile, "..")dirname(cacheFile) for correct path resolution
    • Use atomic temp-file + renameSync in writeCache to prevent race conditions
    • Strip pre-release/build-metadata suffixes in isNewerVersion; add NaN guard
    • Add console.debug logging in fetchLatestVersion catch block
    • Show which package manager command will be run before executing it
    • Suppress update advisory banner when running ghlt update
    • Add showUpdateBanner test suite to banner.test.ts
    • Use process.pid in temp file name to prevent collisions
  • All 100 tests pass, 0 CodeQL alerts
Original prompt

This section details on the original issue you should resolve

<issue_title>feat: add update command and update advisory banner</issue_title>
<issue_description>## Overview

Two related quality-of-life improvements to help users stay on the latest version of ghlt.


Feature 1 — ghlt update command

Add a dedicated update command that self-updates the ghlt CLI to the latest published version.

Expected behavior

$ ghlt update
[INFO] Current version: v0.7.0
[INFO] Latest version:  v0.8.0
[INFO] Updating ghlt...
[LOG]  ghlt updated to v0.8.0

If already up to date:

$ ghlt update
[INFO] Current version: v0.8.0
[LOG]  Already on the latest version.

Implementation notes

  • Check latest version from npm registry (https://registry.npmjs.org/github-labels-template/latest) or GitHub Releases API
  • Run the appropriate package manager update command (npm i -g, bun add -g, etc.) — or instruct the user to do so if auto-update is not feasible
  • Support a --check / --dry-run flag to only report whether an update is available without installing

Feature 2 — Update advisory banner

Show a non-blocking notice at the top of every command run when a newer version of ghlt is available.

Expected behavior

┌─────────────────────────────────────────────────────┐
│  Update available: v0.7.0 → v0.8.0                  │
│  Run ghlt update to upgrade.                        │
└─────────────────────────────────────────────────────┘

A CLI tool to apply a curated GitHub labels template...

Implementation notes

  • Version check should be async and non-blocking — do not delay the main command
  • Cache the last-checked timestamp (e.g., in a local config file) and only re-check once every 24 hours to avoid rate limits and latency on every run
  • Skip the banner when --no-update-notifier flag is passed or NO_UPDATE_NOTIFIER=1 env var is set (standard convention)
  • Skip in CI environments (CI=true)
  • Display the banner after the existing showBanner() call in src/index.ts

Acceptance Criteria

  • ghlt update command is implemented and registered in the CLI
  • ghlt update --check reports version status without updating
  • Update advisory banner displays when a newer version is available
  • Banner is suppressed in CI and via --no-update-notifier / env var
  • Version check is cached (24h TTL) to avoid hitting the registry on every run
  • Tests cover the version comparison logic and cache TTL behavior

Related

  • src/ui/banner.ts — banner display logic
  • src/index.ts — CLI entry point where banner check would be injected
  • src/commands/ — location for the new update.ts command
    </issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Copilot AI changed the title [WIP] Add update command and advisory banner for ghlt feat: add ghlt update command and update advisory banner Feb 23, 2026
@warengonzaga warengonzaga marked this pull request as ready for review February 23, 2026 23:29
@warengonzaga warengonzaga requested a review from Copilot February 23, 2026 23:29
@github-actions
Copy link
Copy Markdown

🔧 Patch Build

Patch version for testing hotfixes

📦 Package Information

  • Package: github-labels-template
  • Version: 0.8.0-patch.30e7740
  • Dist-tag: patch

📥 Installation Instructions

NPM Registry

npm install github-labels-template@0.8.0-patch.30e7740
npm install github-labels-template@patch  # Use dist-tag

View on NPM Registry

GitHub Packages

npm install @warengonzaga/github-labels-template@0.8.0-patch.30e7740
npm install @warengonzaga/github-labels-template@patch  # Use dist-tag

✨ Auto-scoped as @warengonzaga/github-labels-template (from repository owner)

View on GitHub Packages

🔒 Security Audit

No vulnerabilities found


This package was built automatically by the Package Build Flow action.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a self-update command and update advisory banner to help users stay on the latest version of ghlt. The implementation includes version checking utilities with 24-hour cache TTL, automatic package manager detection, and comprehensive test coverage for the core utilities.

Changes:

  • New ghlt update command with --check/--dry-run flags for version management
  • Update advisory banner displayed on CLI startup when newer version is available
  • Version checking utilities with local caching and background refresh mechanism

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/commands/update.ts New command to self-update ghlt with automatic package manager detection
src/utils/updater.ts Core utilities for version comparison, caching, and update checking
src/ui/banner.ts Added showUpdateBanner function to display update advisory
src/index.ts Integrated update check and banner display into CLI entry point
tests/updater.test.ts Comprehensive test coverage for updater utilities (21 tests)

@warengonzaga
Copy link
Copy Markdown
Owner

@copilot apply changes based on the comments in this thread

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 23, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh label list --repo invalid/nonexistent-repo-xyz --json name -q .[].name --limit 100 (http block)
    • Triggering command: /usr/bin/gh gh label list --repo invalid/nonexistent-repo-xyz --json name,color,description --limit 100 (http block)
  • https://api.github.com/repos/invalid/nonexistent-repo-xyz/labels
    • Triggering command: /usr/bin/gh gh label create test --repo invalid/nonexistent-repo-xyz --color 000000 --description test (http block)
  • https://api.github.com/repos/invalid/nonexistent-repo-xyz/labels/nonexistent-label
    • Triggering command: /usr/bin/gh gh label delete nonexistent-label --repo invalid/nonexistent-repo-xyz --yes (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@github-actions
Copy link
Copy Markdown

🔧 Patch Build

Patch version for testing hotfixes

📦 Package Information

  • Package: github-labels-template
  • Version: 0.8.0-patch.f835045
  • Dist-tag: patch

📥 Installation Instructions

NPM Registry

npm install github-labels-template@0.8.0-patch.f835045
npm install github-labels-template@patch  # Use dist-tag

View on NPM Registry

GitHub Packages

npm install @warengonzaga/github-labels-template@0.8.0-patch.f835045
npm install @warengonzaga/github-labels-template@patch  # Use dist-tag

✨ Auto-scoped as @warengonzaga/github-labels-template (from repository owner)

View on GitHub Packages

🔒 Security Audit

No vulnerabilities found


This package was built automatically by the Package Build Flow action.

@warengonzaga warengonzaga merged commit 571a293 into main Feb 24, 2026
1 check passed
@warengonzaga warengonzaga deleted the copilot/add-ghlt-update-command branch February 24, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add update command and update advisory banner

3 participants