From 376806cc7efe266ddbe9c6707fa2d3de36d91cf6 Mon Sep 17 00:00:00 2001 From: Josh Edney Date: Thu, 10 Oct 2024 17:19:31 +0100 Subject: [PATCH 1/9] update where we put the bin for npm/yarn --- install.js | 7 +++++-- package.json | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/install.js b/install.js index bc9070ae..22c2e4a0 100644 --- a/install.js +++ b/install.js @@ -51,7 +51,7 @@ const getPlatformMetadata = () => { const downloadBinaryFromGitHub = async (downloadUrl, outputPath) => { try { - const binDir = path.resolve(process.cwd(),'..','..','.bin'); + const binDir = path.resolve(process.cwd(),'.bin'); if (!fs.existsSync(binDir)) { fs.mkdirSync(binDir, { recursive: true }); } @@ -61,6 +61,9 @@ const downloadBinaryFromGitHub = async (downloadUrl, outputPath) => { fs.writeFileSync(outputPath, binaryData, 'binary'); fs.chmodSync(outputPath, '755'); console.log('Binary downloaded successfully!'); + nodeBinPath = path.join(path.resolve(process.cwd(),'..','..','.bin'),path.basename(outputPath)); + fs.symlinkSync(outputPath, nodeBinPath, 'file'); + } catch (err) { console.error('Error downloading binary:', err.message); } @@ -69,6 +72,6 @@ const downloadBinaryFromGitHub = async (downloadUrl, outputPath) => { const platformMetadata = getPlatformMetadata(); const repoUrl = removeGitPrefixAndSuffix(repository.url); const binaryUrl = `${repoUrl}/releases/download/v${version}/${platformMetadata.ARTIFACT_NAME}`; -const binaryOutputPath = path.join(process.cwd(),'..','..','.bin', platformMetadata.BINARY_NAME); +const binaryOutputPath = path.join(process.cwd(),'.bin', platformMetadata.BINARY_NAME); downloadBinaryFromGitHub(binaryUrl, binaryOutputPath); diff --git a/package.json b/package.json index 5d746618..65369824 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "BugSnag CLI", "main": "install.js", "bin": { - "bugsnag-cli": "bin/bugsnag-cli" + "bugsnag-cli": "./.bin/bugsnag-cli" }, "repository": { "type": "git", From 42c8dc9cc302014886d99baa107514a7123b5fae Mon Sep 17 00:00:00 2001 From: Josh Edney Date: Fri, 11 Oct 2024 10:49:04 +0100 Subject: [PATCH 2/9] update where we put the bin for npm/yarn --- bin/bugsnag-cli | 0 install.js | 7 ++----- package.json | 3 ++- 3 files changed, 4 insertions(+), 6 deletions(-) create mode 100755 bin/bugsnag-cli diff --git a/bin/bugsnag-cli b/bin/bugsnag-cli new file mode 100755 index 00000000..e69de29b diff --git a/install.js b/install.js index 22c2e4a0..6dc80c0b 100644 --- a/install.js +++ b/install.js @@ -51,7 +51,7 @@ const getPlatformMetadata = () => { const downloadBinaryFromGitHub = async (downloadUrl, outputPath) => { try { - const binDir = path.resolve(process.cwd(),'.bin'); + const binDir = path.resolve(process.cwd(),'bin'); if (!fs.existsSync(binDir)) { fs.mkdirSync(binDir, { recursive: true }); } @@ -61,9 +61,6 @@ const downloadBinaryFromGitHub = async (downloadUrl, outputPath) => { fs.writeFileSync(outputPath, binaryData, 'binary'); fs.chmodSync(outputPath, '755'); console.log('Binary downloaded successfully!'); - nodeBinPath = path.join(path.resolve(process.cwd(),'..','..','.bin'),path.basename(outputPath)); - fs.symlinkSync(outputPath, nodeBinPath, 'file'); - } catch (err) { console.error('Error downloading binary:', err.message); } @@ -72,6 +69,6 @@ const downloadBinaryFromGitHub = async (downloadUrl, outputPath) => { const platformMetadata = getPlatformMetadata(); const repoUrl = removeGitPrefixAndSuffix(repository.url); const binaryUrl = `${repoUrl}/releases/download/v${version}/${platformMetadata.ARTIFACT_NAME}`; -const binaryOutputPath = path.join(process.cwd(),'.bin', platformMetadata.BINARY_NAME); +const binaryOutputPath = path.join(process.cwd(),'bin', platformMetadata.BINARY_NAME); downloadBinaryFromGitHub(binaryUrl, binaryOutputPath); diff --git a/package.json b/package.json index 65369824..163fe527 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "BugSnag CLI", "main": "install.js", "bin": { - "bugsnag-cli": "./.bin/bugsnag-cli" + "bugsnag-cli": "bin/bugsnag-cli" }, "repository": { "type": "git", @@ -25,6 +25,7 @@ }, "files": [ "install.js", + "bin/bugsnag-cli", "supported-platforms.yml" ], "scripts": { From 16e5ee29ea9c7d0be7455bebbed2773468a10438 Mon Sep 17 00:00:00 2001 From: Josh Edney Date: Fri, 11 Oct 2024 15:12:09 +0100 Subject: [PATCH 3/9] update changelog --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce1c9c52..6499da8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,12 @@ # Changelog +## TBD + +### Fixes +- Ensure that the node package is configured correctly so that you can run `npx @bugsnag/cli` and `yarn bugsnag-cli`. [144](https://github.com/bugsnag/bugsnag-cli/pull/144) + ## 2.6.1 (2024-09-18) -# Fixes +### Fixes - Ensure that we only pass either `--code-bundle-id` or `--version-code`/`--version-name`/`--bundle-version` to the upload API. [140](https://github.com/bugsnag/bugsnag-cli/pull/140) ## 2.6.0 (2024-09-09) From 62a405c9daea50005fd9b9b28925688b6cc17677 Mon Sep 17 00:00:00 2001 From: Josh Edney Date: Fri, 11 Oct 2024 15:14:43 +0100 Subject: [PATCH 4/9] add error message to holding file --- bin/bugsnag-cli | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/bugsnag-cli b/bin/bugsnag-cli index e69de29b..4b19b76a 100755 --- a/bin/bugsnag-cli +++ b/bin/bugsnag-cli @@ -0,0 +1,3 @@ +#!/usr/bin/env node + +console.log("error - bugsnag-cli binary has not been installed successfully") From bed52383c0260d20d4ad99f840460e755a206646 Mon Sep 17 00:00:00 2001 From: Josh Edney Date: Fri, 11 Oct 2024 15:37:25 +0100 Subject: [PATCH 5/9] 2.6.4-alpha --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 163fe527..7aa5eb52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bugsnag/cli", - "version": "2.6.1", + "version": "2.6.4-alpha", "description": "BugSnag CLI", "main": "install.js", "bin": { From 9e28c5668aeaf8ed10bd25d6a12b0a30caa10f9a Mon Sep 17 00:00:00 2001 From: Josh Edney Date: Tue, 15 Oct 2024 09:20:41 +0100 Subject: [PATCH 6/9] remove axios for fetch --- install.js | 14 ++++++++++---- package.json | 1 - 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/install.js b/install.js index 6dc80c0b..cf08cba0 100644 --- a/install.js +++ b/install.js @@ -1,8 +1,9 @@ -const axios = require('axios'); const fs = require('fs'); const path = require('path'); const os = require('os'); const yaml = require('js-yaml'); +const createWriteStream = require('fs').createWriteStream; +const Readable = require('stream').Readable; const supportedPlatformsConfig = fs.readFileSync(path.join(__dirname, 'supported-platforms.yml'), 'utf8'); const { name, repository, version } = require('./package.json'); @@ -56,9 +57,14 @@ const downloadBinaryFromGitHub = async (downloadUrl, outputPath) => { fs.mkdirSync(binDir, { recursive: true }); } - const response = await axios.get(downloadUrl, { responseType: 'arraybuffer' }); - const binaryData = response.data; - fs.writeFileSync(outputPath, binaryData, 'binary'); + const fileName = downloadUrl.split("/").pop(); + const resp = await fetch(downloadUrl); + + if (resp.ok && resp.body) { + let writer = createWriteStream(outputPath); + Readable.fromWeb(resp.body).pipe(writer); + } + fs.chmodSync(outputPath, '755'); console.log('Binary downloaded successfully!'); } catch (err) { diff --git a/package.json b/package.json index 7aa5eb52..58d6c4e6 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ }, "homepage": "https://github.com/bugsnag/bugsnag-cli#readme", "dependencies": { - "axios": "^1.7.4", "js-yaml": "^4.1.0" }, "files": [ From 17b882a12ff50f8bb03445298f9496a16081b68f Mon Sep 17 00:00:00 2001 From: Josh Edney Date: Tue, 15 Oct 2024 14:12:32 +0100 Subject: [PATCH 7/9] update changelog --- CHANGELOG.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6499da8e..98e721d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Fixes - Ensure that the node package is configured correctly so that you can run `npx @bugsnag/cli` and `yarn bugsnag-cli`. [144](https://github.com/bugsnag/bugsnag-cli/pull/144) +- Replace the axios dependency with fetch to reduce the size of the package. [145](https://github.com/bugsnag/bugsnag-cli/pull/144) ## 2.6.1 (2024-09-18) diff --git a/package.json b/package.json index 58d6c4e6..951435ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bugsnag/cli", - "version": "2.6.4-alpha", + "version": "2.6.1", "description": "BugSnag CLI", "main": "install.js", "bin": { From 04e9d292285423a131c40bf0df85b7807c51d738 Mon Sep 17 00:00:00 2001 From: Josh Edney Date: Tue, 15 Oct 2024 14:16:44 +0100 Subject: [PATCH 8/9] bump version for release --- CHANGELOG.md | 2 +- install.sh | 2 +- main.go | 2 +- package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6499da8e..60811cc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # Changelog -## TBD +## 2.6.2 (TBD) ### Fixes - Ensure that the node package is configured correctly so that you can run `npx @bugsnag/cli` and `yarn bugsnag-cli`. [144](https://github.com/bugsnag/bugsnag-cli/pull/144) diff --git a/install.sh b/install.sh index fae27879..af914e9c 100755 --- a/install.sh +++ b/install.sh @@ -91,7 +91,7 @@ display_help() { EOS } -VERSION="2.6.1" +VERSION="2.6.2" while [[ "$#" -gt 0 ]]; do case "$1" in diff --git a/main.go b/main.go index 0ebbb25d..e695bbcf 100644 --- a/main.go +++ b/main.go @@ -13,7 +13,7 @@ import ( "github.com/bugsnag/bugsnag-cli/pkg/utils" ) -var package_version = "2.6.1" +var package_version = "2.6.2" func main() { commands := options.CLI{} diff --git a/package.json b/package.json index 163fe527..6c923c74 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bugsnag/cli", - "version": "2.6.1", + "version": "2.6.2", "description": "BugSnag CLI", "main": "install.js", "bin": { From cc8e2d37925a96478cdec07d1dad858b8b0eda45 Mon Sep 17 00:00:00 2001 From: Josh Edney Date: Wed, 16 Oct 2024 17:51:29 +0100 Subject: [PATCH 9/9] update date on changelog for v2.6.2 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60811cc2..ec44f506 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # Changelog -## 2.6.2 (TBD) +## 2.6.2 (2024-10-17) ### Fixes - Ensure that the node package is configured correctly so that you can run `npx @bugsnag/cli` and `yarn bugsnag-cli`. [144](https://github.com/bugsnag/bugsnag-cli/pull/144)