iosignal-cli 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,10 +28,40 @@ $ io-server
28
28
  # start server with default option.
29
29
  # default. open port 7777 with WebSocket.
30
30
 
31
+ ┌─────────────────────────────────────────┐
32
+
33
+ WebSocket: Browser or nodejs client
34
+
35
+ - Local: ws://localhost:7777
36
+ - Network: ws://192.168.0.204:7777
37
+
38
+ └─────────────────────────────────────────┘
31
39
 
32
- $ io-server -l 5555
40
+
41
+ $ io-server -l 5555 -L 8888
33
42
  # you can specify listen port number
34
43
 
44
+ ┌───────────────────────────────────────────┐
45
+
46
+ WebSocket: Browser or nodejs client
47
+
48
+ - Local: ws://localhost:5555
49
+ - Network: ws://192.168.0.204:5555
50
+
51
+ CongSocket: nodejs client or CLI
52
+
53
+ - Local: cong://localhost:8888
54
+ - Network: cong://192.168.0.204:8888
55
+
56
+ CongSocket: Arduino client
57
+
58
+ - host: 192.168.0.204
59
+ - port: 8888
60
+
61
+ └───────────────────────────────────────────┘
62
+
63
+
64
+
35
65
  $ io-server -l 0 -L 5555
36
66
  # use number 0 to disable WebSocket service.
37
67
 
@@ -41,7 +71,8 @@ $ io-server -l 0 -L 5555
41
71
 
42
72
 
43
73
  ```sh
44
- $ io # or io alias
74
+ $ io
75
+ # io is an alias name of io-clinet
45
76
  # connect to localhost:7777 with websocket.
46
77
 
47
78
  # use -c to define websocket url and port number.
package/bin/io-server.js CHANGED
@@ -1,12 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import { createClient } from 'redis';
4
+ import { program } from 'commander'
5
+ import { version } from './getVersion.js'
6
+ import { serverInfo } from './serverInfo.js';
3
7
  import {
4
8
  Server, serverOption, Auth_File, Auth_Env, Auth_Redis,
5
9
  api_reply, api_sudo, RedisAPI
6
10
  } from 'iosignal'
7
- import { createClient } from 'redis';
8
- import { program } from 'commander'
9
- import { version } from './getVersion.js'
11
+
12
+
10
13
 
11
14
  program
12
15
  .version(version)
@@ -95,5 +98,4 @@ if (options.showOptions) {
95
98
  console.log('server api list', server.apiNames)
96
99
  }
97
100
 
98
-
99
-
101
+ console.log( serverInfo( serverOption.port , serverOption.congPort ))
@@ -0,0 +1,48 @@
1
+ import { networkInterfaces as getNetworkInterfaces } from 'node:os';
2
+ const networkInterfaces = getNetworkInterfaces();
3
+ import chalk from 'chalk';
4
+ import boxen from 'boxen';
5
+
6
+
7
+ function getNetworkAddress (){
8
+ for (const interfaceDetails of Object.values(networkInterfaces)) {
9
+ if (!interfaceDetails) continue;
10
+
11
+ for (const details of interfaceDetails) {
12
+ const { address, family, internal } = details;
13
+
14
+ if (family === 'IPv4' && !internal) return address;
15
+ }
16
+ }
17
+ };
18
+
19
+
20
+ export function serverInfo ( wsPort, congPort ){
21
+ let ip = getNetworkAddress();
22
+ let message = chalk.green('WebSocket: Browser or nodejs client');
23
+
24
+ const prefix = '- '
25
+ const space = ' '
26
+
27
+ message += `\n\n${chalk.bold(`${prefix}Local:`)}${space}ws://localhost:${wsPort}`;
28
+ message += `\n${chalk.bold('- Network:')} ws://${ip}:${wsPort}`;
29
+
30
+ if(congPort){
31
+ message += `\n\n`;
32
+ message += chalk.green('CongSocket: nodejs client or CLI');
33
+ message += `\n\n${chalk.bold(`${prefix}Local:`)}${space}cong://localhost:${congPort}`;
34
+ message += `\n${chalk.bold('- Network:')} cong://${ip}:${congPort}`;
35
+
36
+ message += `\n\n`;
37
+ message += chalk.green('CongSocket: Arduino client');
38
+ message += `\n\n${chalk.bold(`${prefix}host:`)} ${ip}`;
39
+ message += `\n${chalk.bold('- port:')} ${congPort }`;
40
+
41
+ }
42
+
43
+ return boxen(message, { padding: 1, borderColor: 'green', margin: 1, })
44
+
45
+ }
46
+
47
+
48
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iosignal-cli",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "IOSignal server and client CLI program.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -16,18 +16,26 @@
16
16
  },
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
+ "boxen": "^7.1.1",
20
+ "chalk": "^5.3.0",
19
21
  "commander": "^11.1.0",
20
22
  "iosignal": "^1.0.0",
21
23
  "meta-buffer-pack": "^1.3.1",
22
24
  "redis": "^4.6.12"
23
- }
24
- ,
25
+ },
25
26
  "repository": {
26
27
  "type": "git",
27
28
  "url": "git://github.com/remocons/iosignal-cli.git"
28
29
  },
29
30
  "homepage": "https://iosignal.net",
30
31
  "keywords": [
31
- "io","pubsub","arduino","iot","auth","signal","CLI","remocon"
32
+ "io",
33
+ "pubsub",
34
+ "arduino",
35
+ "iot",
36
+ "auth",
37
+ "signal",
38
+ "CLI",
39
+ "remocon"
32
40
  ]
33
41
  }