diff --git a/CHANGELOG.md b/CHANGELOG.md index ce1c9c52..e25df30a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,13 @@ # Changelog +## 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) +- 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) -# 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) diff --git a/bin/bugsnag-cli b/bin/bugsnag-cli new file mode 100755 index 00000000..4b19b76a --- /dev/null +++ b/bin/bugsnag-cli @@ -0,0 +1,3 @@ +#!/usr/bin/env node + +console.log("error - bugsnag-cli binary has not been installed successfully") diff --git a/install.js b/install.js index bc9070ae..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'); @@ -51,14 +52,19 @@ 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 }); } - 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) { @@ -69,6 +75,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/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 5d746618..bb829dcb 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": { @@ -20,11 +20,11 @@ }, "homepage": "https://github.com/bugsnag/bugsnag-cli#readme", "dependencies": { - "axios": "^1.7.4", "js-yaml": "^4.1.0" }, "files": [ "install.js", + "bin/bugsnag-cli", "supported-platforms.yml" ], "scripts": {