mirror of https://github.com/waku-org/js-waku.git
Connect cli chat to prod fleet upon passing `--prod`
This commit is contained in:
parent
a69c483c46
commit
c4c259f47a
|
@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- **Breaking**: Modify `WakuStore.queryHistory()` to accept one `Object` instead of multiple individual arguments.
|
- **Breaking**: Modify `WakuStore.queryHistory()` to accept one `Object` instead of multiple individual arguments.
|
||||||
- `getStatusFleetNodes` return prod nodes by default, instead of test nodes.
|
- `getStatusFleetNodes` return prod nodes by default, instead of test nodes.
|
||||||
- Examples (web chat): Connect to prod fleet by default, test fleet for local development.
|
- Examples (web chat): Connect to prod fleet by default, test fleet for local development.
|
||||||
|
- Examples (cli chat): Connect to test fleet by default, use `--prod` to connect to prod fleet.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Expose `Enviroment` and `Protocol` enums to pass to `getStatusFleetNodes`.
|
- Expose `Enviroment` and `Protocol` enums to pass to `getStatusFleetNodes`.
|
||||||
|
|
|
@ -3,6 +3,7 @@ import util from 'util';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ChatMessage,
|
ChatMessage,
|
||||||
|
Environment,
|
||||||
getStatusFleetNodes,
|
getStatusFleetNodes,
|
||||||
StoreCodec,
|
StoreCodec,
|
||||||
Waku,
|
Waku,
|
||||||
|
@ -105,6 +106,7 @@ interface Options {
|
||||||
staticNodes: Multiaddr[];
|
staticNodes: Multiaddr[];
|
||||||
listenAddr: string;
|
listenAddr: string;
|
||||||
autoDial: boolean;
|
autoDial: boolean;
|
||||||
|
prod: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
function processArguments(): Options {
|
function processArguments(): Options {
|
||||||
|
@ -114,6 +116,7 @@ function processArguments(): Options {
|
||||||
listenAddr: '/ip4/0.0.0.0/tcp/0',
|
listenAddr: '/ip4/0.0.0.0/tcp/0',
|
||||||
staticNodes: [],
|
staticNodes: [],
|
||||||
autoDial: false,
|
autoDial: false,
|
||||||
|
prod: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
while (passedArgs.length) {
|
while (passedArgs.length) {
|
||||||
|
@ -128,6 +131,9 @@ function processArguments(): Options {
|
||||||
case '--autoDial':
|
case '--autoDial':
|
||||||
opts.autoDial = true;
|
opts.autoDial = true;
|
||||||
break;
|
break;
|
||||||
|
case '--prod':
|
||||||
|
opts.prod = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
console.log(`Unsupported argument: ${arg}`);
|
console.log(`Unsupported argument: ${arg}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
@ -149,7 +155,9 @@ export function formatMessage(chatMsg: ChatMessage): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addFleetNodes(opts: Options): Promise<Options> {
|
async function addFleetNodes(opts: Options): Promise<Options> {
|
||||||
await getStatusFleetNodes().then((nodes) =>
|
await getStatusFleetNodes(
|
||||||
|
opts.prod ? Environment.Prod : Environment.Test
|
||||||
|
).then((nodes) =>
|
||||||
nodes.map((addr) => {
|
nodes.map((addr) => {
|
||||||
opts.staticNodes.push(multiaddr(addr));
|
opts.staticNodes.push(multiaddr(addr));
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue