Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gh-release-fetch

Package Overview
Dependencies
Maintainers
21
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gh-release-fetch - npm Package Compare versions

Comparing version 3.0.2 to 4.0.0

dist/index.test.d.ts

2

dist/index.d.ts
import { RequestInit } from 'node-fetch';
declare type DownloadOptions = Pick<RequestInit, 'agent'>;
type DownloadOptions = Pick<RequestInit, 'agent'>;
export interface Release {

@@ -4,0 +4,0 @@ repository: string;

@@ -1,12 +0,7 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.newerVersion = exports.updateAvailable = exports.fetchVersion = exports.fetchLatest = void 0;
const fs_1 = require("fs");
const download_1 = __importDefault(require("download"));
const node_fetch_1 = __importDefault(require("node-fetch"));
const semver_1 = require("semver");
async function fetchLatest(release, fetchOptions) {
import { promises as fs } from 'fs';
// @ts-expect-error this module does not have types itself, we need to use `download` types
import download from '@xhmikosr/downloader';
import fetch from 'node-fetch';
import { gt } from 'semver';
export async function fetchLatest(release, fetchOptions) {
// eslint-disable-next-line no-param-reassign

@@ -17,16 +12,13 @@ release.version = await resolveRelease(release.repository, fetchOptions);

}
exports.fetchLatest = fetchLatest;
async function fetchVersion(release, { agent } = {}) {
export async function fetchVersion(release, { agent } = {}) {
validateRelease(release);
await downloadFile(release, { agent });
}
exports.fetchVersion = fetchVersion;
async function updateAvailable(repository, currentVersion, fetchOptions) {
export async function updateAvailable(repository, currentVersion, fetchOptions) {
const latestVersion = await resolveRelease(repository, fetchOptions);
return newerVersion(latestVersion, currentVersion);
}
exports.updateAvailable = updateAvailable;
async function resolveRelease(repository, fetchOptions) {
const res = await (0, node_fetch_1.default)(`https://api.github.com/repos/${repository}/releases/latest`, fetchOptions);
const json = await res.json();
const res = await fetch(`https://api.github.com/repos/${repository}/releases/latest`, fetchOptions);
const json = (await res.json());
if (res.status === 403 && typeof json.message === 'string' && json.message.includes('API rate limit exceeded')) {

@@ -39,6 +31,6 @@ throw new Error('API rate limit exceeded, please try again later');

const url = `https://github.com/${release.repository}/releases/download/${release.version}/${release.package}`;
await fs_1.promises.mkdir(release.destination, { recursive: true });
await (0, download_1.default)(url, release.destination, {
await fs.mkdir(release.destination, { recursive: true });
await download(url, release.destination, {
extract: release.extract,
agent: agent,
agent: { https: agent },
});

@@ -60,3 +52,3 @@ }

}
function newerVersion(latestVersion, currentVersion) {
export function newerVersion(latestVersion, currentVersion) {
if (!latestVersion) {

@@ -70,4 +62,3 @@ return false;

const normalizedCurrentVersion = currentVersion.replace(/^v/, '');
return (0, semver_1.gt)(normalizedLatestVersion, normalizedCurrentVersion);
return gt(normalizedLatestVersion, normalizedCurrentVersion);
}
exports.newerVersion = newerVersion;
{
"name": "gh-release-fetch",
"version": "3.0.2",
"version": "4.0.0",
"description": "A library to fetch release binaries from GitHub Releases",
"main": "dist/index.js",
"type": "module",
"files": [
"dist/*.{js,ts}"
"dist"
],
"scripts": {
"prepare": "husky install node_modules/@netlify/eslint-config-node/.husky/",
"prepublishOnly": "npm ci && run-s build test",
"test": "jest",
"prepublishOnly": "npm ci && npm run build",
"test": "vitest run",
"test:ci": "vitest run --coverage",
"build": "tsc",

@@ -25,4 +27,4 @@ "build:watch": "tsc --watch",

"config": {
"eslint": "--ignore-path .gitignore --cache --format=codeframe --max-warnings=0 \"{src,tests,.github}/**/*.{ts,js,html}\" \"*.{ts,js,html}\" \".*.{ts,js,html}\"",
"prettier": "--ignore-path .gitignore --loglevel=warn \"{src,tests,.github}/**/*.{ts,js,md,yml,json,html}\" \"*.{ts,js,yml,json,html}\" \".*.{ts,js,yml,json,html}\" \"!package-lock.json\""
"eslint": "--report-unused-disable-directives --ignore-path .gitignore --cache --format=codeframe --max-warnings=0 \"{src,tests,.github}/**/*.{mjs,cjs,js,mts,cts,ts,html}\" \"*.{cjs,mjs,js,cts,mts,ts,html}\" \".*.{cjs,mjs,js,cts,mts,ts,html}\"",
"prettier": "--loglevel=warn \"{src,tests,.github}/**/*.{cjs,mjs,js,cts,mts,ts,md,yml,json,html}\" \"*.{cjs,mjs,js,cts,mts,ts,yml,json,html}\" \".*.{cjs,mjs,js,cts,mts,ts,yml,json,html}\" \"!package-lock.json\""
},

@@ -35,3 +37,3 @@ "keywords": [

"engines": {
"node": "^12.20.0 || ^14.14.0 || >=16.0.0"
"node": "^14.18.0 || ^16.13.0 || >=18.0.0"
},

@@ -41,18 +43,18 @@ "author": "David Calavera",

"devDependencies": {
"@netlify/eslint-config-node": "^5.1.7",
"@types/jest": "^27.0.0",
"@types/node": "^16.0.0",
"husky": "^7.0.4",
"jest": "^27.0.0",
"ts-jest": "^27.0.0",
"typescript": "^4.0.0"
"@netlify/eslint-config-node": "7.0.1",
"@types/download": "8.0.2",
"@types/node": "14.18.46",
"@types/semver": "7.5.0",
"@vitest/coverage-c8": "0.31.0",
"husky": "8.0.3",
"npm-run-all": "4.1.5",
"tempy": "3.0.0",
"typescript": "5.0.4",
"vitest": "0.31.0"
},
"dependencies": {
"@types/download": "^8.0.0",
"@types/node-fetch": "^2.1.6",
"@types/semver": "^7.0.0",
"download": "^8.0.0",
"node-fetch": "^2.3.0",
"@xhmikosr/downloader": "^9.0.0",
"node-fetch": "^3.0.0",
"semver": "^7.0.0"
}
}

@@ -10,5 +10,5 @@ # Release Fetch

```ts
import * from 'release-fetch'
import { fetchLatest } from 'gh-release-fetch'
fetchLatest({ repository: 'netlify/netlify-cli', package: 'cli.tar.gz', destination: 'dist' });
fetchLatest({ repository: 'netlify/netlify-cli', package: 'cli.tar.gz', destination: 'dist' })
```

@@ -15,0 +15,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc