-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,712 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,120 @@ | ||
# pbsb-cli | ||
command-line interface for pbsb | ||
|
||
# how to use | ||
``` | ||
pbsb-cli -h | ||
``` | ||
|
||
## help | ||
``` | ||
Usage: pbsb-cli [options] [command] | ||
command-line interface for pbsb | ||
Options: | ||
-V, --version output the version number | ||
-h, --help display help for command | ||
Commands: | ||
call [options] <pathname> simple call server | ||
pub [options] <string> publish message | ||
sub [options] subcribe message | ||
req [options] request message | ||
consume [options] <filename> consume message from message queue | ||
produce [options] <filename> produce message to message queue | ||
help [command] display help for command | ||
``` | ||
|
||
## call | ||
``` | ||
Usage: pbsb-cli call [options] <pathname> | ||
simple call server | ||
Arguments: | ||
pathname pathname | ||
Options: | ||
--json format response body to json (default: true) | ||
-s, --server [address] server address (default: "localhost:9292") | ||
-p, --payload [string] payload data | ||
-q, --query [string] query data | ||
-h, --help display help for command | ||
``` | ||
|
||
## pub | ||
``` | ||
Usage: pbsb-cli pub [options] <string> | ||
publish message | ||
Arguments: | ||
string message body | ||
Options: | ||
--json auto try format response body to json (default: true) | ||
-c, --channel <name> channel name | ||
-s, --server [address] server address (default: "localhost:9292") | ||
-m, --multicast message multicast (default: true) | ||
-c, --cache message cache (default: false) | ||
-h, --help display help for command | ||
``` | ||
|
||
## sub | ||
``` | ||
Usage: pbsb-cli sub [options] | ||
subcribe message | ||
Options: | ||
--json auto try format response body to json (default: true) | ||
-c, --channel <name> channel name | ||
-s, --server [address] server address (default: "localhost:9292") | ||
-m, --mime [string] custom mime type | ||
-p, --persist persist connect (default: false) | ||
-h, --help display help for command | ||
``` | ||
|
||
## consume | ||
``` | ||
Usage: pbsb-cli consume [options] <filename> | ||
consume message from message queue | ||
Arguments: | ||
filename consumer javascript filename | ||
Options: | ||
-s, --server [address] server address (default: "localhost:9292") | ||
-c, --channel <name> message queue namespace | ||
-a, --ack auto ack when message fetched | ||
-p, --priority [weight] The weight of the current consumer in the priority | ||
(default: "0") | ||
-d, --dead fetch messages from the dead letter queue | ||
-h, --help display help for command | ||
``` | ||
|
||
## produce | ||
``` | ||
Usage: pbsb-cli produce [options] <filename> | ||
produce message to message queue | ||
Arguments: | ||
filename producer javascript filename | ||
Options: | ||
-s, --server [address] server address (default: "localhost:9292") | ||
-c, --channel <name> message queue namespace | ||
-h, --help display help for command | ||
``` | ||
|
||
# todo | ||
- [ ] host http server | ||
- [ ] chat | ||
- [ ] file share | ||
- [ ] signature auth | ||
- [ ] support typescript for worker | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
process.on("message", (data) => { | ||
console.log(data); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
process.on("message", (data) => { | ||
console.log(data); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# examples | ||
> After all, it is a command line program and only a very small part of the code logic will be involved in each run, so instead of implementing dedicated unit tests, some simple use cases are placed under this folder to ensure usability. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "pbsb-cli", | ||
"description": "command-line interface for pbsb", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"repository": "https://github.com/zhzLuke96/pbsb-cli", | ||
"author": "zhzluke96 <[email protected]>", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^22.0.1", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^13.3.0", | ||
"@types/node": "^18.6.3", | ||
"commander": "^9.4.0", | ||
"cross-env": "^7.0.3", | ||
"esbuild": "^0.14.51", | ||
"nodemon": "^2.0.19", | ||
"rollup": "^2.77.2", | ||
"rollup-plugin-esbuild": "^4.9.1", | ||
"ts-node": "^10.9.1", | ||
"tslib": "^2.4.0", | ||
"typescript": "^4.7.4" | ||
}, | ||
"scripts": { | ||
"start": "ts-node ./src/index.ts", | ||
"build:rollup": "rollup -c", | ||
"build": "cross-env NODE_ENV=production bash ./scripts/build.sh", | ||
"build:dev": "bash ./scripts/build.sh" | ||
}, | ||
"dependencies": { | ||
"parse-headers": "^2.0.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import cjs from "@rollup/plugin-commonjs"; | ||
import resolve from "@rollup/plugin-node-resolve"; | ||
import esbuild from "rollup-plugin-esbuild"; | ||
import json from "@rollup/plugin-json"; | ||
|
||
const production = process.env.NODE_ENV === 'production'; | ||
|
||
export default [ | ||
{ | ||
input: `src/index.ts`, | ||
plugins: [ | ||
resolve(), | ||
cjs(), | ||
json(), | ||
esbuild({ | ||
minify: production, | ||
minifyIdentifiers: production, | ||
minifySyntax: production, | ||
minifyWhitespace: production, | ||
}), | ||
], | ||
output: [ | ||
{ | ||
file: `dist/pbsb-cli.js`, | ||
format: "cjs", | ||
sourcemap: !production, | ||
exports: "named", | ||
}, | ||
], | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
set -e | ||
|
||
__scriptdir=$(cd "$(dirname "$0")";pwd) | ||
__rootdir=$(cd "$__scriptdir";cd ..;pwd) | ||
__distdir=$(cd "$__scriptdir";cd ../dist;pwd) | ||
|
||
rm -rf $__distdir/* | ||
|
||
cd $__rootdir | ||
yarn build:rollup | ||
|
||
cp $__rootdir/package.json $__distdir/package.json | ||
|
||
cd $__distdir | ||
pkg -C GZip pbsb-cli.js | ||
|
||
zip -r -9 "$__distdir/output.zip" . | ||
zip -r -9 "$__distdir/output-win.zip" ./pbsb-cli-win.exe | ||
zip -r -9 "$__distdir/output-linux.zip" ./pbsb-cli-linux | ||
zip -r -9 "$__distdir/output-macos.zip" ./pbsb-cli-macos |
Oops, something went wrong.