{"id":35439103,"url":"https://github.com/captainsafia/gh-release-update-notifier","last_synced_at":"2026-01-13T19:59:52.777Z","repository":{"id":331018678,"uuid":"1124865589","full_name":"captainsafia/gh-release-update-notifier","owner":"captainsafia","description":"TypeScript library for checking GitHub releases to notify users of available updates.","archived":false,"fork":false,"pushed_at":"2026-01-02T21:57:34.000Z","size":66,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-09T09:58:48.571Z","etag":null,"topics":["github","github-releases","typescript","update-notifier"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/captainsafia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-29T18:47:05.000Z","updated_at":"2026-01-02T21:34:10.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/captainsafia/gh-release-update-notifier","commit_stats":null,"previous_names":["captainsafia/gh-release-update-notifier"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/captainsafia/gh-release-update-notifier","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/captainsafia%2Fgh-release-update-notifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/captainsafia%2Fgh-release-update-notifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/captainsafia%2Fgh-release-update-notifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/captainsafia%2Fgh-release-update-notifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/captainsafia","download_url":"https://codeload.github.com/captainsafia/gh-release-update-notifier/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/captainsafia%2Fgh-release-update-notifier/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28398703,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github","github-releases","typescript","update-notifier"],"created_at":"2026-01-02T23:22:35.436Z","updated_at":"2026-01-13T19:59:52.772Z","avatar_url":"https://github.com/captainsafia.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gh-release-update-notifier\n\nA lightweight TypeScript library for checking GitHub Releases to notify CLI users of available updates, with built-in caching and disk persistence.\n\n## Installation\n\n```bash\nnpm install gh-release-update-notifier\n```\n\n```bash\npnpm add gh-release-update-notifier\n```\n\n```bash\nyarn add gh-release-update-notifier\n```\n\n## Usage\n\n### Basic Usage\n\n```typescript\nimport { ReleaseNotifier } from 'gh-release-update-notifier';\n\nconst notifier = new ReleaseNotifier({\n  repo: 'owner/repo',\n});\n\n// Check if an update is available\nconst result = await notifier.checkVersion('1.0.0');\n\nif (result.updateAvailable) {\n  console.log(`Update available: ${result.latestVersion}`);\n  console.log(`Download: ${result.latestRelease?.htmlUrl}`);\n}\n```\n\n### Get Latest Release\n\n```typescript\nconst notifier = new ReleaseNotifier({ repo: 'owner/repo' });\n\n// Get the latest stable release\nconst stable = await notifier.getLatestRelease();\nconsole.log(`Latest stable: ${stable?.tagName}`);\n\n// Include prereleases in the search\nconst latest = await notifier.getLatestRelease(true);\nconsole.log(`Latest (including prereleases): ${latest?.tagName}`);\n```\n\n### Get Latest Prerelease\n\n```typescript\nconst notifier = new ReleaseNotifier({ repo: 'owner/repo' });\n\nconst prerelease = await notifier.getLatestPrerelease();\nif (prerelease) {\n  console.log(`Latest prerelease: ${prerelease.tagName}`);\n}\n```\n\n### Check Version with Prereleases\n\n```typescript\nconst notifier = new ReleaseNotifier({ repo: 'owner/repo' });\n\n// Check against the latest prerelease\nconst result = await notifier.checkVersion('2.0.0-beta.1', true);\n\nif (result.updateAvailable) {\n  console.log(`New prerelease available: ${result.latestVersion}`);\n}\n```\n\n### Caching Configuration\n\n```typescript\nconst notifier = new ReleaseNotifier({\n  repo: 'owner/repo',\n  // Check interval in milliseconds (default: 1 hour)\n  checkInterval: 3600000,\n  // Optional: persist cache to disk\n  cacheFilePath: '/path/to/cache.json',\n});\n\n// Clear the cache manually\nnotifier.clearCache();\n```\n\n## API Reference\n\n### `ReleaseNotifier`\n\n#### Constructor Options\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `repo` | `string` | **required** | GitHub repository in `owner/repo` format |\n| `checkInterval` | `number` | `3600000` (1 hour) | Minimum time between API requests (in ms). Set to `0` to disable caching. |\n| `cacheFilePath` | `string` | `undefined` | Path to persist cache on disk |\n| `token` | `string` | `undefined` | GitHub token for authentication (increases rate limits and enables access to private repos) |\n\n#### Methods\n\n##### `getLatestRelease(includePrerelease?: boolean): Promise\u003cRelease | null\u003e`\n\nFetches the most recent release from GitHub.\n\n- `includePrerelease` - When `true`, includes prereleases in the search (default: `false`)\n- Returns the latest release or `null` if no releases found\n\n##### `getLatestPrerelease(): Promise\u003cRelease | null\u003e`\n\nFetches the most recent prerelease from GitHub.\n\n- Returns the latest prerelease or `null` if no prereleases found\n\n##### `checkVersion(currentVersion: string, isPrerelease?: boolean): Promise\u003cVersionCheckResult\u003e`\n\nChecks if the provided version is older than the latest available version.\n\n- `currentVersion` - The version/tag to check (e.g., `\"1.2.3\"` or `\"v1.2.3\"`)\n- `isPrerelease` - When `true`, checks against the latest prerelease (default: `false`)\n- Returns version check result with update availability information\n\n##### `clearCache(): void`\n\nClears the cached releases, forcing the next fetch to get fresh data. Also removes the cache file from disk if configured.\n\n### Types\n\n#### `Release`\n\n```typescript\ninterface Release {\n  tagName: string;\n  name: string;\n  prerelease: boolean;\n  draft: boolean;\n  htmlUrl: string;\n  publishedAt: string;\n}\n```\n\n#### `VersionCheckResult`\n\n```typescript\ninterface VersionCheckResult {\n  updateAvailable: boolean;\n  currentVersion: string;\n  latestVersion: string | null;\n  latestRelease: Release | null;\n}\n```\n\n#### `ReleaseNotifierConfig`\n\n```typescript\ninterface ReleaseNotifierConfig {\n  repo: string;\n  checkInterval?: number;\n  cacheFilePath?: string;\n  token?: string;\n}\n```\n\n## CLI Integration Example\n\n```typescript\nimport { ReleaseNotifier } from 'gh-release-update-notifier';\nimport { readFileSync } from 'node:fs';\n\nconst pkg = JSON.parse(readFileSync('./package.json', 'utf-8'));\n\nconst notifier = new ReleaseNotifier({\n  repo: 'your-org/your-cli',\n  checkInterval: 86400000, // Check once per day\n  cacheFilePath: `${process.env.HOME}/.your-cli/update-cache.json`,\n  token: process.env.GITHUB_TOKEN, // Optional: for higher rate limits\n});\n\nasync function checkForUpdates() {\n  try {\n    const result = await notifier.checkVersion(pkg.version);\n    \n    if (result.updateAvailable) {\n      console.log(`\\n📦 Update available: ${pkg.version} → ${result.latestVersion}`);\n      console.log(`   Run: npm install -g your-cli`);\n      console.log(`   Or visit: ${result.latestRelease?.htmlUrl}\\n`);\n    }\n  } catch {\n    // Silently fail - don't block the CLI for update checks\n  }\n}\n\n// Run update check in the background\ncheckForUpdates();\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaptainsafia%2Fgh-release-update-notifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaptainsafia%2Fgh-release-update-notifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaptainsafia%2Fgh-release-update-notifier/lists"}