Update notifications for your CLI app
Overall
score
97%
Build a class-based package update monitoring system that checks for updates and stores check history with proper data encapsulation.
Create a PackageMonitor class that tracks update checks for a package and stores historical check data. The class should:
The class should properly encapsulate its internal data, preventing external code from directly accessing or modifying the check history and package information.
@generates
/**
* Monitors package updates with proper data encapsulation
*/
class PackageMonitor {
/**
* Creates a new PackageMonitor instance
* @param {string} packageName - The name of the package to monitor
* @param {string} currentVersion - The current version of the package
*/
constructor(packageName, currentVersion) {}
/**
* Records an update check
* @param {string} latestVersion - The latest version found during the check
* @returns {void}
*/
recordCheck(latestVersion) {}
/**
* Gets the most recent check information
* @returns {Object|null} Object with {timestamp, latestVersion} or null if no checks
*/
getLastCheck() {}
/**
* Gets the total number of checks performed
* @returns {number} The count of checks
*/
getCheckCount() {}
/**
* Gets the package name (read-only access)
* @returns {string} The package name
*/
getPackageName() {}
/**
* Gets the current version (read-only access)
* @returns {string} The current version
*/
getCurrentVersion() {}
}
module.exports = { PackageMonitor };Provides inspiration for class-based architecture patterns and encapsulation techniques used in update monitoring systems.
Install with Tessl CLI
npx tessl i tessl/npm-update-notifierdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10