CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-update-notifier

Update notifications for your CLI app

Overall
score

97%

Overview
Eval results
Files

task.mdevals/scenario-3/

CLI Version Monitor

Build a command-line tool that checks for updates and displays version information without blocking the user's workflow.

Requirements

Your tool should implement the following functionality:

  1. Package Information: Accept package name and current version as configuration
  2. Background Update Checking: Implement a mechanism to check for newer versions without blocking the CLI startup or execution
  3. Update Notification Display: When an update is available, display a notification to the user with current and latest version information
  4. Persistent State: Store the last check time and update information so it persists across runs
  5. Check Interval: Only perform update checks at configurable intervals (default: 1 day) to avoid excessive API calls

Behavior

  • On first run, initiate an update check in the background but do not display a notification
  • On subsequent runs, if an update was detected and the information is available, display it to the user
  • The update check should not delay or block the CLI tool from completing its main task
  • After displaying an update notification once, clear it so it doesn't show repeatedly on every run

Test Cases

Create test cases in test/version-monitor.test.js that verify:

  • Background check is initiated without blocking @test
  • Update information is persisted and retrieved correctly @test
  • Notification displays when update is available @test
  • Check interval is respected to avoid redundant checks @test

Implementation

@generates

API

/**
 * Creates and initializes a version monitor
 * @param {Object} config - Configuration object
 * @param {string} config.name - Package name
 * @param {string} config.version - Current version
 * @param {number} [config.checkInterval=86400000] - Interval between checks in milliseconds
 * @returns {Object} Version monitor instance with check() and notify() methods
 */
function createVersionMonitor(config) {
  // Implementation
}

module.exports = { createVersionMonitor };

Dependencies { .dependencies }

update-notifier { .dependency }

Provides update detection and notification functionality for CLI applications.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-update-notifier

tile.json