iosignal-cli 1.0.0 → 1.1.0

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
@@ -13,7 +13,9 @@ $ npm install -g iosignal-cli
13
13
 
14
14
  # If NO Permissioin error, use sudo prefix.
15
15
  $ sudo npm install -g iosignal-cli
16
+
16
17
  ```
18
+
17
19
  windows as admin permission
18
20
  ```sh
19
21
  # global install.
@@ -28,10 +30,40 @@ $ io-server
28
30
  # start server with default option.
29
31
  # default. open port 7777 with WebSocket.
30
32
 
33
+ ┌─────────────────────────────────────────┐
34
+
35
+ WebSocket: Browser or nodejs client
36
+
37
+ - Local: ws://localhost:7777
38
+ - Network: ws://192.168.0.204:7777
39
+
40
+ └─────────────────────────────────────────┘
41
+
31
42
 
32
43
  $ io-server -l 5555
33
44
  # you can specify listen port number
34
45
 
46
+ ┌───────────────────────────────────────────┐
47
+
48
+ WebSocket: Browser or nodejs client
49
+
50
+ - Local: ws://localhost:5555
51
+ - Network: ws://192.168.0.204:5555
52
+
53
+ CongSocket: nodejs client or CLI
54
+
55
+ - Local: cong://localhost:8888
56
+ - Network: cong://192.168.0.204:8888
57
+
58
+ CongSocket: Arduino client
59
+
60
+ - host: 192.168.0.204
61
+ - port: 8888
62
+
63
+ └───────────────────────────────────────────┘
64
+
65
+
66
+
35
67
  $ io-server -l 0 -L 5555
36
68
  # use number 0 to disable WebSocket service.
37
69
 
@@ -41,7 +73,8 @@ $ io-server -l 0 -L 5555
41
73
 
42
74
 
43
75
  ```sh
44
- $ io # or io alias
76
+ $ io
77
+ # io is an alias name of io-clinet
45
78
  # connect to localhost:7777 with websocket.
46
79
 
47
80
  # 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.0",
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
  }