biz-a-cli 2.3.60 → 2.3.61

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.
@@ -57,10 +57,10 @@ export function directHubEvent(serverSocket, argv){
57
57
  // shall not log in production mode
58
58
  if (process.env.NODE_ENV !== 'production') {
59
59
  const id = `<${clientSocket.handshake?.query?.isClient ? `Client` : clientSocket.handshake?.query?.isDeploy ? 'Deployer' : 'Anonymous'}> ${clientSocket.id}`;
60
+ console.log(id, `connected`)
60
61
  clientSocket.on('disconnect', (reason)=>{
61
62
  console.log(id, `disconnected. Reason : ${reason}`)
62
63
  })
63
- console.log(id, `connected`)
64
64
  };
65
65
  })
66
66
  }
package/bin/hub.js CHANGED
@@ -1,5 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ if (!process.env.NODE_ENV) {
4
+ process.env.NODE_ENV = 'production';
5
+ };
6
+
3
7
  import yargs from 'yargs';
4
8
  import { io as ioClient } from "socket.io-client";
5
9
  import { streamEvent, hubEvent, RECONNECT_SOCKET_DELAY } from './hubEvent.js'
@@ -87,7 +91,8 @@ const argv = yargs(process.argv.slice(2))
87
91
  type: 'number',
88
92
  demandOption: false
89
93
  })
90
- .options('hub', {
94
+ .options('hs', {
95
+ alias: 'hubServer',
91
96
  default: `${env.BIZA_HUB_SERVER_LINK}`,
92
97
  describe: 'BizA hub',
93
98
  type: 'string',
@@ -129,6 +134,10 @@ app.set('args', argv);
129
134
 
130
135
  app.use('/cb', runCliScript);
131
136
 
137
+ app.use('/status', (req, res)=>{
138
+ res.status(200).json(argv.cliAddress());
139
+ });
140
+
132
141
  // create HTTP(s) Server
133
142
  const keyFile = path.join(import.meta.dirname, "../cert/key.pem")
134
143
  const certFile = path.join(import.meta.dirname, "../cert/cert.pem")
@@ -148,8 +157,8 @@ server.listen(argv.serverport, () => {
148
157
  await streamEvent(ioClient(argv['server'], {query: {isSockStream: true }}), argv); // as socket client to BizA SERVER
149
158
 
150
159
  // as socket client to BizA HUB
151
- if (argv.hub) {
152
- hubEvent(ioClient(argv['hub'], { reconnectionDelay: RECONNECT_SOCKET_DELAY, reconnectionDelayMax: RECONNECT_SOCKET_DELAY, query: {isCLI: true, room: argv['subdomain']} }), argv, (url)=>{
160
+ if (argv.hubServer) {
161
+ hubEvent(ioClient(argv['hubServer'], { reconnectionDelay: RECONNECT_SOCKET_DELAY, reconnectionDelayMax: RECONNECT_SOCKET_DELAY, query: {isCLI: true, room: argv['subdomain']} }), argv, (url)=>{
153
162
  if (url!==argv.connectedHubUrl) {
154
163
  argv.connectedHubUrl = url
155
164
  }
package/bin/hubEvent.js CHANGED
@@ -134,8 +134,8 @@ export const hubEvent = (socket, argv, notifier)=>{
134
134
  let id
135
135
  socket.on('connect', ()=>{
136
136
  id = socket.id
137
- notifier(argv['hub'])
138
- console.log(`${new Date()}: ${getIdText(id)}connected to BizA Hub at ${argv['hub']} using sub domain "${argv['subdomain']}"`)
137
+ notifier(argv['hubServer'])
138
+ console.log(`${new Date()}: ${getIdText(id)}connected to BizA Hub at ${argv['hubServer']} using sub domain "${argv['subdomain']}"`)
139
139
  })
140
140
  socket.on('disconnect', (reason)=>{
141
141
  notifier('')
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "biz-a-cli",
3
3
  "nameDev": "biz-a-cli-dev",
4
- "version": "2.3.60",
4
+ "version": "2.3.61",
5
5
  "versionDev": "0.0.34",
6
6
  "description": "",
7
7
  "main": "bin/index.js",
@@ -14,7 +14,7 @@
14
14
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch a",
15
15
  "testOnce": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
16
16
  "dev": "node --watch server.js",
17
- "hub": "set NODE_ENV=production && node --experimental-vm-modules bin/hub.js"
17
+ "hub": "set NODE_ENV=dev&& node --experimental-vm-modules bin/hub.js"
18
18
  },
19
19
  "author": "Imamatek",
20
20
  "license": "ISC",
package/tests/hub.test.js CHANGED
@@ -154,7 +154,7 @@ describe('Hub event tests', () => {
154
154
  port: 212,
155
155
  serverport: 3002,
156
156
  cliAddress: ()=>{return {ip: '59.60.1.22', port: '3002', address: `59.60.1.22:3002`, publicUrl: 'https://some.public.url', hubUrl: 'https://some.hub.url'}},
157
- hub: 'https://some.hub.url'
157
+ hubServer: 'https://some.hub.url'
158
158
  })
159
159
 
160
160
  mockAPIServer = net.createServer((clientSocket)=>{
@@ -363,7 +363,7 @@ describe('Hub event tests', () => {
363
363
  port,
364
364
  serverport: 3002,
365
365
  cliAddress: ()=>{return {ip: '59.60.1.22', port: '3002', address: `59.60.1.22:3002`, publicUrl: 'https://some.tunnel.url'}},
366
- hub: 'https://some.hub.url'
366
+ hubServer: 'https://some.hub.url'
367
367
  },
368
368
  (hubUrl)=>{
369
369
  expect(hubUrl).toBe('https://some.hub.url')