From fe7cf914579ce0af43ceb8d15df21629e6681cc5 Mon Sep 17 00:00:00 2001 From: fraxken Date: Tue, 19 Mar 2024 12:05:31 +0100 Subject: [PATCH 1/5] chore: update @myunisoft/httpie (1.11.0 to 4.0.1) --- package.json | 94 ++++++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/package.json b/package.json index e845eed..578ecdf 100644 --- a/package.json +++ b/package.json @@ -1,47 +1,47 @@ -{ - "name": "@nodesecure/github", - "version": "1.2.0", - "description": "Download repository from github", - "type": "module", - "exports": "./index.js", - "scripts": { - "prepublishOnly": "pkg-ok", - "test": "node -r dotenv --test", - "coverage": "c8 -r html npm test" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/NodeSecure/github.git" - }, - "keywords": [ - "NodeSecure", - "github", - "download", - "archive" - ], - "files": [ - "index.js", - "index.d.ts" - ], - "author": "GENTILHOMME Thomas ", - "license": "MIT", - "bugs": { - "url": "https://github.com/NodeSecure/github/issues" - }, - "homepage": "https://github.com/NodeSecure/github#readme", - "dependencies": { - "@myunisoft/httpie": "^1.10.0", - "tar-fs": "^2.1.1" - }, - "devDependencies": { - "@nodesecure/eslint-config": "^1.5.0", - "@slimio/is": "^2.0.0", - "c8": "^9.1.0", - "dotenv": "^16.0.2", - "eslint": "^8.23.0", - "pkg-ok": "^3.0.0" - }, - "engines": { - "node": ">=18" - } -} +{ + "name": "@nodesecure/github", + "version": "1.2.0", + "description": "Download repository from github", + "type": "module", + "exports": "./index.js", + "scripts": { + "prepublishOnly": "pkg-ok", + "test": "node -r dotenv --test", + "coverage": "c8 -r html npm test" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/NodeSecure/github.git" + }, + "keywords": [ + "NodeSecure", + "github", + "download", + "archive" + ], + "files": [ + "index.js", + "index.d.ts" + ], + "author": "GENTILHOMME Thomas ", + "license": "MIT", + "bugs": { + "url": "https://github.com/NodeSecure/github/issues" + }, + "homepage": "https://github.com/NodeSecure/github#readme", + "dependencies": { + "@myunisoft/httpie": "^4.0.1", + "tar-fs": "^2.1.1" + }, + "devDependencies": { + "@nodesecure/eslint-config": "^1.5.0", + "@slimio/is": "^2.0.0", + "c8": "^9.1.0", + "dotenv": "^16.0.2", + "eslint": "^8.23.0", + "pkg-ok": "^3.0.0" + }, + "engines": { + "node": ">=18" + } +} From 994a28825e17ea8563ee851fb0b351e9b01d7b7d Mon Sep 17 00:00:00 2001 From: fraxken Date: Tue, 19 Mar 2024 12:05:33 +0100 Subject: [PATCH 2/5] chore: update tar-fs (2.1.1 to 3.0.5) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 578ecdf..3e3dd68 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "homepage": "https://github.com/NodeSecure/github#readme", "dependencies": { "@myunisoft/httpie": "^4.0.1", - "tar-fs": "^2.1.1" + "tar-fs": "^3.0.5" }, "devDependencies": { "@nodesecure/eslint-config": "^1.5.0", From 8e4435cc3d25c853e522b86cc0e308ab1216d2cf Mon Sep 17 00:00:00 2001 From: fraxken Date: Tue, 19 Mar 2024 12:08:53 +0100 Subject: [PATCH 3/5] fix: propertly use new httpie writableCallback --- index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 50ef001..308bd45 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ // Import Node.js Dependencies +import * as fs from "node:fs/promises"; +import * as path from "node:path"; import { createWriteStream, createReadStream } from "node:fs"; -import fs from "node:fs/promises"; -import path from "node:path"; import { createGunzip } from "node:zlib"; import { pipeline } from "node:stream/promises"; @@ -37,14 +37,15 @@ export async function download(repository, options = Object.create(null)) { const repositoryURL = new URL(`${organization}/${repo}/archive/${branch}.tar.gz`, kGithubURL); const location = path.join(dest, `${repo}-${branch}.tar.gz`); - await httpie.stream("GET", repositoryURL, { + const writableCallback = httpie.stream("GET", repositoryURL, { headers: { "User-Agent": "NodeSecure", "Accept-Encoding": "gzip, deflate", Authorization: typeof token === "string" ? `token ${token}` : GITHUB_TOKEN }, maxRedirections: 1 - })(createWriteStream(location)); + }); + await writableCallback(() => createWriteStream(location)); return { location, From deb282a0ea52dca653bc9c79371b5301ffd7dfbd Mon Sep 17 00:00:00 2001 From: fraxken Date: Tue, 19 Mar 2024 12:09:48 +0100 Subject: [PATCH 4/5] fix: remove dotenv from production codebase --- index.js | 2 -- package.json | 94 ++++++++++++++++++++++++++-------------------------- 2 files changed, 47 insertions(+), 49 deletions(-) diff --git a/index.js b/index.js index 308bd45..737e941 100644 --- a/index.js +++ b/index.js @@ -8,8 +8,6 @@ import { pipeline } from "node:stream/promises"; // Import Third-party Dependencies import tar from "tar-fs"; import httpie from "@myunisoft/httpie"; -import * as dotenv from "dotenv"; -dotenv.config(); // CONSTANTS const kGithubURL = new URL("https://github.com/"); diff --git a/package.json b/package.json index 3e3dd68..d57c006 100644 --- a/package.json +++ b/package.json @@ -1,47 +1,47 @@ -{ - "name": "@nodesecure/github", - "version": "1.2.0", - "description": "Download repository from github", - "type": "module", - "exports": "./index.js", - "scripts": { - "prepublishOnly": "pkg-ok", - "test": "node -r dotenv --test", - "coverage": "c8 -r html npm test" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/NodeSecure/github.git" - }, - "keywords": [ - "NodeSecure", - "github", - "download", - "archive" - ], - "files": [ - "index.js", - "index.d.ts" - ], - "author": "GENTILHOMME Thomas ", - "license": "MIT", - "bugs": { - "url": "https://github.com/NodeSecure/github/issues" - }, - "homepage": "https://github.com/NodeSecure/github#readme", - "dependencies": { - "@myunisoft/httpie": "^4.0.1", - "tar-fs": "^3.0.5" - }, - "devDependencies": { - "@nodesecure/eslint-config": "^1.5.0", - "@slimio/is": "^2.0.0", - "c8": "^9.1.0", - "dotenv": "^16.0.2", - "eslint": "^8.23.0", - "pkg-ok": "^3.0.0" - }, - "engines": { - "node": ">=18" - } -} +{ + "name": "@nodesecure/github", + "version": "1.2.0", + "description": "Download repository from github", + "type": "module", + "exports": "./index.js", + "scripts": { + "prepublishOnly": "pkg-ok", + "test": "node -r dotenv --test", + "coverage": "c8 -r html npm test" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/NodeSecure/github.git" + }, + "keywords": [ + "NodeSecure", + "github", + "download", + "archive" + ], + "files": [ + "index.js", + "index.d.ts" + ], + "author": "GENTILHOMME Thomas ", + "license": "MIT", + "bugs": { + "url": "https://github.com/NodeSecure/github/issues" + }, + "homepage": "https://github.com/NodeSecure/github#readme", + "dependencies": { + "@myunisoft/httpie": "^4.0.1", + "tar-fs": "^3.0.5" + }, + "devDependencies": { + "@nodesecure/eslint-config": "^1.5.0", + "@slimio/is": "^2.0.0", + "c8": "^9.1.0", + "dotenv": "^16.0.2", + "eslint": "^8.23.0", + "pkg-ok": "^3.0.0" + }, + "engines": { + "node": ">=18" + } +} From 4703701b2d9c18d458bbd2d9fee0f5e3693bcc47 Mon Sep 17 00:00:00 2001 From: fraxken Date: Tue, 19 Mar 2024 12:10:46 +0100 Subject: [PATCH 5/5] chore(package): update @myunisoft/eslint-config --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d57c006..38b370a 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "tar-fs": "^3.0.5" }, "devDependencies": { - "@nodesecure/eslint-config": "^1.5.0", + "@nodesecure/eslint-config": "^1.9.0", "@slimio/is": "^2.0.0", "c8": "^9.1.0", "dotenv": "^16.0.2",