diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0495e46..62d1c8c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,13 +40,16 @@ jobs: zip -qq -r stm-linux-v${{ steps.package-version.outputs.current-version}}.zip . -i stm-linux zip -qq -r stm-alpine-v${{ steps.package-version.outputs.current-version}}.zip . -i stm-alpine zip -qq -r stm-win-v${{ steps.package-version.outputs.current-version}}.zip . -i stm-win.exe - rm stm-macos stm-linux stm-alpine stm-win.exe cd .. - name: Publish artifacts to github uses: softprops/action-gh-release@v1 with: - files: release/* + files: | + release/stm-macos-v${{ steps.package-version.outputs.current-version}}.zip + release/stm-linux-v${{ steps.package-version.outputs.current-version}}.zip + release/stm-alpine-v${{ steps.package-version.outputs.current-version}}.zip + release/stm-win-v${{ steps.package-version.outputs.current-version}}.zip - name: Update Homebrew run: ./scripts/update_homebrew.sh ${{ steps.package-version.outputs.current-version}} diff --git a/package.json b/package.json index bd9093b..172fbbe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@solace-community/stm", - "version": "0.0.56", + "version": "0.0.57", "description": "Solace Try-Me Command Line Tool", "repository": { "type": "git", @@ -44,7 +44,6 @@ "express": "^4.18.2", "form-data": "^4.0.0", "hexdump-nodejs": "^0.1.0", - "istextorbinary": "^9.5.0", "http": "^0.0.1-security", "json-schema-library": "^10.0.0-rc1", "node-localstorage": "^3.0.5", diff --git a/src/lib/publish.ts b/src/lib/publish.ts index 5b65513..bd38367 100644 --- a/src/lib/publish.ts +++ b/src/lib/publish.ts @@ -6,7 +6,16 @@ import { getDefaultMessage, delay } from '../utils/defaults'; import { displayHelpExamplesForPublish } from '../utils/examples'; import { fileExists, saveOrUpdateCommandSettings } from '../utils/config'; import { StdinRead } from '../utils/stdinread' -const { isText, isBinary, getEncoding } = require('istextorbinary') + +const isBinaryFile = (filePath: string): boolean => { + const fileBuffer = fs.readFileSync(filePath); + for (let i = 0; i < 24; i++) { + if (fileBuffer[i] === 0) { + return true; + } + } + return false; +}; const publish = async ( options: MessageClientOptions, @@ -50,13 +59,13 @@ const publish = async ( } try { - const binary = isBinary(file); - if (binary) { + if (isBinaryFile(file)) { message = fs.readFileSync(file, 'binary'); payloadType = 'bytes'; } else { message = fs.readFileSync(file, 'utf8'); } + } catch (error: any) { Logger.logDetailedError('read file failed', error.toString()) if (error.cause?.message) Logger.logDetailedError(``, `${error.cause?.message}`) diff --git a/yarn.lock b/yarn.lock index 2a149fa..7ff4ea2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -650,13 +650,6 @@ base64-js@^1.3.1: resolved "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz" integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== -binaryextensions@^6.11.0: - version "6.11.0" - resolved "https://registry.npmjs.org/binaryextensions/-/binaryextensions-6.11.0.tgz" - integrity sha512-sXnYK/Ij80TO3lcqZVV2YgfKN5QjUWIRk/XSm2J/4bd/lPko3lvk0O4ZppH6m+6hB2/GTu+ptNwVFe1xh+QLQw== - dependencies: - editions "^6.21.0" - bl@^4.0.3: version "4.1.0" resolved "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz" @@ -965,13 +958,6 @@ ebnf@^1.9.1: resolved "https://registry.npmjs.org/ebnf/-/ebnf-1.9.1.tgz" integrity sha512-uW2UKSsuty9ANJ3YByIQE4ANkD8nqUPO7r6Fwcc1ADKPe9FRdcPpMl3VEput4JSvKBJ4J86npIC2MLP0pYkCuw== -editions@^6.21.0: - version "6.21.0" - resolved "https://registry.npmjs.org/editions/-/editions-6.21.0.tgz" - integrity sha512-ofkXJtn7z0urokN62DI3SBo/5xAtF0rR7tn+S/bSYV79Ka8pTajIIl+fFQ1q88DQEImymmo97M4azY3WX/nUdg== - dependencies: - version-range "^4.13.0" - ee-first@1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz" @@ -1676,15 +1662,6 @@ isarray@~1.0.0: resolved "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz" integrity sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ== -istextorbinary@^9.5.0: - version "9.5.0" - resolved "https://registry.npmjs.org/istextorbinary/-/istextorbinary-9.5.0.tgz" - integrity sha512-5mbUj3SiZXCuRf9fT3ibzbSSEWiy63gFfksmGfdOzujPjW3k+z8WvIBxcJHBoQNlaZaiyB25deviif2+osLmLw== - dependencies: - binaryextensions "^6.11.0" - editions "^6.21.0" - textextensions "^6.11.0" - js-yaml@^4.1.0: version "4.1.0" resolved "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz" @@ -2614,13 +2591,6 @@ tar-stream@^2.1.4: inherits "^2.0.3" readable-stream "^3.1.1" -textextensions@^6.11.0: - version "6.11.0" - resolved "https://registry.npmjs.org/textextensions/-/textextensions-6.11.0.tgz" - integrity sha512-tXJwSr9355kFJI3lbCkPpUH5cP8/M0GGy2xLO34aZCjMXBaK3SoPnZwr/oWmo1FdCnELcs4npdCIOFtq9W3ruQ== - dependencies: - editions "^6.21.0" - to-fast-properties@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz" @@ -2816,11 +2786,6 @@ vary@~1.1.2: resolved "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz" integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== -version-range@^4.13.0: - version "4.14.0" - resolved "https://registry.npmjs.org/version-range/-/version-range-4.14.0.tgz" - integrity sha512-gjb0ARm9qlcBAonU4zPwkl9ecKkas+tC2CGwFfptTCWWIVTWY1YUbT2zZKsOAF1jR/tNxxyLwwG0cb42XlYcTg== - webidl-conversions@^3.0.0: version "3.0.1" resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz"