iosignal-cli 3.1.1 → 3.2.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/bin/io-client.js CHANGED
@@ -1,11 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { IO, IOCongSocket, ENC_MODE, serverOption } from 'iosignal'
4
3
  import { EventEmitter } from 'events'
5
4
  import readline from 'readline'
6
5
  import tty from 'tty'
7
6
  import { program } from 'commander'
8
- import { version } from './getVersion.js'
7
+
8
+ import { IO, IOCongSocket, ENC_MODE, version as iosignal_version } from 'iosignal'
9
+ import pkg from '../package.json' with { type: 'json' };
10
+ const cli_version = pkg.version;
11
+ const version = `CLI ${cli_version} IOSignal ${iosignal_version}`
12
+
9
13
 
10
14
  class Console extends EventEmitter {
11
15
  constructor() {
package/bin/io-server.js CHANGED
@@ -2,13 +2,15 @@
2
2
 
3
3
  import { createClient } from 'redis';
4
4
  import { program } from 'commander'
5
- import { version } from './getVersion.js'
6
5
  import { serverInfo } from './serverInfo.js';
7
6
  import {
8
7
  Server, serverOption, Auth_File, Auth_Env, Auth_Redis,
9
- api_reply, api_sudo, RedisAPI
8
+ api_reply, api_sudo, RedisAPI, version as iosignal_version
10
9
  } from 'iosignal'
11
10
 
11
+ import pkg from '../package.json' with { type: 'json' };
12
+ const cli_version = pkg.version;
13
+ const version = `CLI ${cli_version} IOSignal ${iosignal_version}`
12
14
 
13
15
 
14
16
  program
@@ -30,20 +32,13 @@ program
30
32
 
31
33
  const options = program.opts()
32
34
 
35
+ // global shared serverOption
33
36
  if (options.fileLogger) {
34
37
  serverOption.fileLogger.connection.use = true;
35
38
  serverOption.fileLogger.auth.use = true;
36
39
  serverOption.fileLogger.attack.use = true;
37
40
  }
38
41
 
39
- if (options.listen) {
40
- serverOption.port = parseInt(options.listen)
41
- }
42
-
43
- if (options.listenCongport) {
44
- serverOption.congPort = parseInt(options.listenCongport)
45
- }
46
-
47
42
  if (options.showMessage) {
48
43
  serverOption.showMessage = options.showMessage
49
44
  }
@@ -56,6 +51,15 @@ if (options.timeout) {
56
51
  serverOption.timeout = options.timeout
57
52
  }
58
53
 
54
+ // private port, congPort
55
+ let privateServerOptions = { };
56
+ if (options.listen) {
57
+ privateServerOptions.port = parseInt(options.listen)
58
+ }
59
+
60
+ if (options.listenCongport) {
61
+ privateServerOptions.congPort = parseInt(options.listenCongport)
62
+ }
59
63
 
60
64
  let authManager;
61
65
  let redisClient;
@@ -81,7 +85,7 @@ if (options.authFile) {
81
85
  }
82
86
 
83
87
 
84
- const server = new Server(serverOption, authManager)
88
+ const server = new Server( privateServerOptions , authManager);
85
89
 
86
90
  if (options.apiList && options.apiList.length > 0) {
87
91
  let apiList = options.apiList
@@ -93,12 +97,14 @@ if (options.apiList && options.apiList.length > 0) {
93
97
  }
94
98
 
95
99
  if (options.showOptions) {
96
- console.log('ServerOptions:', serverOption)
100
+ console.log('global ServerOptions:', serverOption)
101
+ console.log('private ServerOptions:', privateServerOptions)
97
102
  console.log('server api list', server.apiNames)
98
103
  }
99
104
 
100
- console.log(serverInfo(serverOption.port, serverOption.congPort))
101
-
102
- if (!serverOption.port && !serverOption.congPort) {
103
- process.exit()
104
- }
105
+ setTimeout(()=>{
106
+ console.log(serverInfo(server))
107
+ if ( server.port === null && server.congPort === null ) {
108
+ process.exit();
109
+ }
110
+ },1000)
package/bin/serverInfo.js CHANGED
@@ -17,12 +17,12 @@ export function getNetworkAddress (){
17
17
  };
18
18
 
19
19
 
20
- export function serverInfo ( wsPort, congPort ){
21
- // console.log('wsPort', wsPort, 'congPort', congPort)
20
+ export function serverInfo ( server ){
21
+
22
22
  let ip = getNetworkAddress();
23
23
  let message
24
24
 
25
- if( wsPort || congPort ){
25
+ if( server.port == 0 || server.port || server.congPort == 0 || server.congPort ){
26
26
  message = chalk.green('Serving');
27
27
  }else{
28
28
  message = chalk.green('please use -l and -L option to select port number.');
@@ -39,27 +39,27 @@ export function serverInfo ( wsPort, congPort ){
39
39
  const prefix = '- '
40
40
  const space = ' '
41
41
 
42
- if(wsPort){
42
+ if(server.port == 0 || server.port){
43
43
  message += `\n\n`;
44
44
  message += chalk.green('IOSignal Over WebSocket');
45
45
  message += chalk.yellow('\n\n Web Browser & Node.js');
46
- message += `\n ${chalk.bold(`${prefix}Local:`)}${space}ws://localhost:${wsPort}`;
47
- message += `\n ${chalk.bold('- Network:')} ws://${ip}:${wsPort}`;
46
+ message += `\n ${chalk.bold(`${prefix}Local:`)}${space}ws://localhost:${server.port}`;
47
+ message += `\n ${chalk.bold('- Network:')} ws://${ip}:${server.port}`;
48
48
  }else{
49
49
 
50
50
  }
51
51
 
52
- if(congPort){
52
+ if(server.congPort == 0 || server.congPort){
53
53
  message += `\n\n`;
54
54
  message += chalk.green('IOSignal Over CongSocket');
55
55
  message += chalk.yellow('\n\n Node.js');
56
56
 
57
- message += `\n ${chalk.bold(`${prefix}Local:`)}${space}cong://localhost:${congPort}`;
58
- message += `\n ${chalk.bold('- Network:')} cong://${ip}:${congPort}`;
57
+ message += `\n ${chalk.bold(`${prefix}Local:`)}${space}cong://localhost:${server.congPort}`;
58
+ message += `\n ${chalk.bold('- Network:')} cong://${ip}:${server.congPort}`;
59
59
 
60
60
  message += chalk.yellow('\n\n Arduino');
61
61
  message += `\n ${chalk.bold(`${prefix}host:`)} ${ip}`;
62
- message += `\n ${chalk.bold('- port:')} ${congPort }`;
62
+ message += `\n ${chalk.bold('- port:')} ${server.congPort }`;
63
63
 
64
64
  }
65
65
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iosignal-cli",
3
- "version": "3.1.1",
3
+ "version": "3.2.0",
4
4
  "description": "IOSignal server and client CLI program.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -21,7 +21,7 @@
21
21
  "boxen": "8.0.1",
22
22
  "chalk": "5.6.2",
23
23
  "commander": "13.1.0",
24
- "iosignal": "^3.1.0",
24
+ "iosignal": "^3.2.0",
25
25
  "redis": "4.7.1"
26
26
  },
27
27
  "repository": {
package/bin/getVersion.js DELETED
@@ -1,9 +0,0 @@
1
- import { readFile } from 'fs/promises';
2
-
3
- const json = JSON.parse(
4
- await readFile(
5
- new URL('../package.json', import.meta.url)
6
- )
7
- );
8
-
9
- export let version = json.version