Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): message pack format support #1769

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions .github/workflows/build_cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ jobs:
npm install -g pkg
pkg package.json

- uses: actions/upload-artifact@v2
with:
name: cli
path: cli/release
# - uses: actions/upload-artifact@v3
# with:
# name: cli
# path: cli/release

- name: upload release asset
if: github.event_name == 'release'
run: |
cd cli/release
for var in $(ls); do
$GITHUB_WORKSPACE/.github/workflows/upload_github_release_asset.sh \
owner=${{ github.repository_owner }} \
repo=mqttx \
tag=$(echo ${{ github.ref }} | sed -r "s ^refs/heads/|^refs/tags/(.*) \1 g") \
filename=$var \
github_api_token=$(echo ${{ secrets.GITHUB_TOKEN }})
done
# - name: upload release asset
# if: github.event_name == 'release'
# run: |
# cd cli/release
# for var in $(ls); do
# $GITHUB_WORKSPACE/.github/workflows/upload_github_release_asset.sh \
# owner=${{ github.repository_owner }} \
# repo=mqttx \
# tag=$(echo ${{ github.ref }} | sed -r "s ^refs/heads/|^refs/tags/(.*) \1 g") \
# filename=$var \
# github_api_token=$(echo ${{ secrets.GITHUB_TOKEN }})
# done

publish_docker:
if: github.event_name == 'release'
Expand Down
1 change: 1 addition & 0 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"json-bigint": "^1.0.0",
"lodash": "^4.17.21",
"mqtt": "^4.3.7",
"msgpackr": "^1.11.0",
"ora": "^5.4.1",
"protobufjs": "^7.2.3",
"pump": "^3.0.0",
Expand Down
1 change: 1 addition & 0 deletions cli/src/__tests__/utils/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ describe('parse utilities', () => {
expect(parseFormat('hex')).toBe('hex')
expect(parseFormat('cbor')).toBe('cbor')
expect(parseFormat('binary')).toBe('binary')
expect(parseFormat('msgpack')).toBe('msgpack')
})

it('should throw an error for invalid format types', () => {
Expand Down
8 changes: 6 additions & 2 deletions cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class Commander {
.option('-p, --port <PORT>', 'the broker port', parseNumber, state.getConfig('port'))
.option(
'-f, --format <TYPE>',
'the format type of the input message, support base64, json, hex, binary and cbor',
'the format type of the input message, support base64, json, hex, binary, cbor and msgpack',
parseFormat,
)
.option('-i, --client-id <ID>', 'the client id', getClientId())
Expand Down Expand Up @@ -273,7 +273,11 @@ export class Commander {
'the user properties of MQTT 5.0 (e.g. -up "name: mqttx cli")',
parseKeyValues,
)
.option('-f, --format <TYPE>', 'format the message body, support base64, json, hex, binary and cbor', parseFormat)
.option(
'-f, --format <TYPE>',
'format the message body, support base64, json, hex, binary, cbor and msgpack',
parseFormat,
)
.option('-v, --verbose', 'turn on verbose mode to display incoming MQTT packets')
.option(
'--output-mode <default/clean>',
Expand Down
2 changes: 1 addition & 1 deletion cli/src/utils/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const parseFileWrite = (value: string) => {
}

const parseFormat = (value: string) => {
if (!['base64', 'json', 'hex', 'cbor', 'binary'].includes(value)) {
if (!['base64', 'json', 'hex', 'cbor', 'binary', 'msgpack'].includes(value)) {
logWrapper.fail('Not a valid format type.')
process.exit(1)
}
Expand Down
63 changes: 63 additions & 0 deletions cli/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,36 @@
"@jridgewell/resolve-uri" "^3.1.0"
"@jridgewell/sourcemap-codec" "^1.4.14"

"@msgpackr-extract/msgpackr-extract-darwin-arm64@3.0.3":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@msgpackr-extract/msgpackr-extract-darwin-arm64/-/msgpackr-extract-darwin-arm64-3.0.3.tgz#9edec61b22c3082018a79f6d1c30289ddf3d9d11"
integrity sha512-QZHtlVgbAdy2zAqNA9Gu1UpIuI8Xvsd1v8ic6B2pZmeFnFcMWiPLfWXh7TVw4eGEZ/C9TH281KwhVoeQUKbyjw==

"@msgpackr-extract/msgpackr-extract-darwin-x64@3.0.3":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@msgpackr-extract/msgpackr-extract-darwin-x64/-/msgpackr-extract-darwin-x64-3.0.3.tgz#33677a275204898ad8acbf62734fc4dc0b6a4855"
integrity sha512-mdzd3AVzYKuUmiWOQ8GNhl64/IoFGol569zNRdkLReh6LRLHOXxU4U8eq0JwaD8iFHdVGqSy4IjFL4reoWCDFw==

"@msgpackr-extract/msgpackr-extract-linux-arm64@3.0.3":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@msgpackr-extract/msgpackr-extract-linux-arm64/-/msgpackr-extract-linux-arm64-3.0.3.tgz#19edf7cdc2e7063ee328403c1d895a86dd28f4bb"
integrity sha512-YxQL+ax0XqBJDZiKimS2XQaf+2wDGVa1enVRGzEvLLVFeqa5kx2bWbtcSXgsxjQB7nRqqIGFIcLteF/sHeVtQg==

"@msgpackr-extract/msgpackr-extract-linux-arm@3.0.3":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@msgpackr-extract/msgpackr-extract-linux-arm/-/msgpackr-extract-linux-arm-3.0.3.tgz#94fb0543ba2e28766c3fc439cabbe0440ae70159"
integrity sha512-fg0uy/dG/nZEXfYilKoRe7yALaNmHoYeIoJuJ7KJ+YyU2bvY8vPv27f7UKhGRpY6euFYqEVhxCFZgAUNQBM3nw==

"@msgpackr-extract/msgpackr-extract-linux-x64@3.0.3":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@msgpackr-extract/msgpackr-extract-linux-x64/-/msgpackr-extract-linux-x64-3.0.3.tgz#4a0609ab5fe44d07c9c60a11e4484d3c38bbd6e3"
integrity sha512-cvwNfbP07pKUfq1uH+S6KJ7dT9K8WOE4ZiAcsrSes+UY55E/0jLYc+vq+DO7jlmqRb5zAggExKm0H7O/CBaesg==

"@msgpackr-extract/msgpackr-extract-win32-x64@3.0.3":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@msgpackr-extract/msgpackr-extract-win32-x64/-/msgpackr-extract-win32-x64-3.0.3.tgz#0aa5502d547b57abfc4ac492de68e2006e417242"
integrity sha512-x0fWaQtYp4E6sktbsdAqnehxDgEc/VwM7uLsRCYWaiGu0ykYdZPiS8zCWdnjHwyiumousxfBm4SO31eXqwEZhQ==

"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2":
version "1.1.2"
resolved "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz"
Expand Down Expand Up @@ -1359,6 +1389,11 @@ defaults@^1.0.3:
dependencies:
clone "^1.0.2"

detect-libc@^2.0.1:
version "2.0.3"
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.3.tgz#f0cd503b40f9939b894697d19ad50895e30cf700"
integrity sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==

detect-newline@^3.0.0:
version "3.1.0"
resolved "https://registry.npmmirror.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651"
Expand Down Expand Up @@ -2358,6 +2393,27 @@ ms@2.1.2:
resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==

msgpackr-extract@^3.0.2:
version "3.0.3"
resolved "https://registry.yarnpkg.com/msgpackr-extract/-/msgpackr-extract-3.0.3.tgz#e9d87023de39ce714872f9e9504e3c1996d61012"
integrity sha512-P0efT1C9jIdVRefqjzOQ9Xml57zpOXnIuS+csaB4MdZbTdmGDLo8XhzBG1N7aO11gKDDkJvBLULeFTo46wwreA==
dependencies:
node-gyp-build-optional-packages "5.2.2"
optionalDependencies:
"@msgpackr-extract/msgpackr-extract-darwin-arm64" "3.0.3"
"@msgpackr-extract/msgpackr-extract-darwin-x64" "3.0.3"
"@msgpackr-extract/msgpackr-extract-linux-arm" "3.0.3"
"@msgpackr-extract/msgpackr-extract-linux-arm64" "3.0.3"
"@msgpackr-extract/msgpackr-extract-linux-x64" "3.0.3"
"@msgpackr-extract/msgpackr-extract-win32-x64" "3.0.3"

msgpackr@^1.11.0:
version "1.11.0"
resolved "https://registry.yarnpkg.com/msgpackr/-/msgpackr-1.11.0.tgz#8321d52333048cadc749f56385e3231e65337091"
integrity sha512-I8qXuuALqJe5laEBYoFykChhSXLikZmUhccjGsPuSJ/7uPip2TJ7lwdIQwWSAi0jGZDXv4WOP8Qg65QZRuXxXw==
optionalDependencies:
msgpackr-extract "^3.0.2"

mute-stream@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-1.0.0.tgz#e31bd9fe62f0aed23520aa4324ea6671531e013e"
Expand All @@ -2368,6 +2424,13 @@ natural-compare@^1.4.0:
resolved "https://registry.npmmirror.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==

node-gyp-build-optional-packages@5.2.2:
version "5.2.2"
resolved "https://registry.yarnpkg.com/node-gyp-build-optional-packages/-/node-gyp-build-optional-packages-5.2.2.tgz#522f50c2d53134d7f3a76cd7255de4ab6c96a3a4"
integrity sha512-s+w+rBWnpTMwSFbaE0UXsRlg7hU4FjekKU4eyAih5T8nJuNZT1nNsskXpxmeqSK9UzkBl6UgRlnKc8hz8IEqOw==
dependencies:
detect-libc "^2.0.1"

node-int64@^0.4.0:
version "0.4.0"
resolved "https://registry.npmmirror.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
Expand Down
Loading