Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #504

Merged
merged 2 commits into from
Feb 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,761 changes: 671 additions & 1,090 deletions npm-shrinkwrap.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"fast-deep-equal": "^3.1.3",
"mixin-deep": "^2.0.1",
"mz": "^2.7.0",
"serialport": "9.2.8",
"serialport": "10.3.0",
"slip": "^1.0.2"
},
"deprecated": false,
Expand All @@ -55,7 +55,7 @@
"eslint": "*",
"jest": "*",
"regenerator-runtime": "*",
"typedoc": "^0.22.11",
"typedoc": "^0.22.12",
"typedoc-plugin-markdown": "*",
"typedoc-plugin-no-inherit": "*",
"typedoc-plugin-sourcefile-url": "*",
Expand Down
4 changes: 2 additions & 2 deletions src/adapter/deconz/driver/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable */
import Debug from 'debug';
import events from 'events';
import SerialPort from 'serialport';
import {SerialPort} from 'serialport';
import Writer from './writer';
import Parser from './parser';
import Frame from './frame';
Expand Down Expand Up @@ -166,7 +166,7 @@ class Driver extends events.EventEmitter {

public openSerialPort(): Promise<void> {
debug(`Opening with ${this.path}`);
this.serialPort = new SerialPort(this.path, {baudRate: 38400, autoOpen: false});
this.serialPort = new SerialPort({path: this.path, baudRate: 38400, autoOpen: false});

this.writer = new Writer();
// @ts-ignore
Expand Down
9 changes: 5 additions & 4 deletions src/adapter/ezsp/driver/uart.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* istanbul ignore file */
import {EventEmitter} from 'events';
import SerialPort from 'serialport';
import {SerialPort} from 'serialport';
import net from 'net';
import SocketPortUtils from '../../socketPortUtils';
import {Deferred, crc16ccitt} from './utils';
Expand Down Expand Up @@ -180,11 +180,12 @@ export class SerialDriver extends EventEmitter {
const options = {
baudRate: typeof opt.baudRate === 'number' ? opt.baudRate : 115200,
rtscts: typeof opt.rtscts === 'boolean' ? opt.rtscts : false,
autoOpen: false
autoOpen: false,
path: path,
};

debug(`Opening SerialPort with ${path} and ${JSON.stringify(options)}`);
this.serialPort = new SerialPort(path, options);
debug(`Opening SerialPort with ${JSON.stringify(options)}`);
this.serialPort = new SerialPort(options);

this.writer = new Writer();
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand Down
2 changes: 1 addition & 1 deletion src/adapter/serialPortUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import SerialPort from 'serialport';
import {SerialPort} from 'serialport';
import {EqualsPartial} from '../utils';

interface PortInfoMatch {
Expand Down
8 changes: 4 additions & 4 deletions src/adapter/z-stack/znp/znp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import ZpiObject from './zpiObject';
import {ZpiObjectPayload} from './tstype';
import {Subsystem, Type} from '../unpi/constants';

import SerialPort from 'serialport';
import {SerialPort} from 'serialport';
import net from 'net';
import events from 'events';
import Equals from 'fast-deep-equal/es6';
Expand Down Expand Up @@ -126,10 +126,10 @@ class Znp extends events.EventEmitter {
}

private async openSerialPort(): Promise<void> {
const options = {baudRate: this.baudRate, rtscts: this.rtscts, autoOpen: false};
const options = {baudRate: this.baudRate, rtscts: this.rtscts, autoOpen: false, path: this.path};

debug.log(`Opening SerialPort with ${this.path} and ${JSON.stringify(options)}`);
this.serialPort = new SerialPort(this.path, options);
debug.log(`Opening SerialPort with ${JSON.stringify(options)}`);
this.serialPort = new SerialPort(options);

this.unpiWriter = new UnpiWriter();
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand Down
10 changes: 6 additions & 4 deletions src/adapter/zigate/driver/zigate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* istanbul ignore file */
/* eslint-disable */

import SerialPort from 'serialport';
import {SerialPort} from 'serialport';
import { DelimiterParser } from '@serialport/parser-delimiter'
import {EventEmitter} from 'events';
import {Debug} from '../debug';
import SerialPortUtils from "../../serialPortUtils";
Expand Down Expand Up @@ -202,16 +203,17 @@ export default class ZiGate extends EventEmitter {
}

private async openSerialPort(): Promise<void> {
this.serialPort = new SerialPort(this.path, {
this.serialPort = new SerialPort({
baudRate: this.baudRate,
path: this.path,
dataBits: 8,
parity: 'none', /* one of ['none', 'even', 'mark', 'odd', 'space'] */
stopBits: 1, /* one of [1,2] */
lock: false,
autoOpen: false
});
this.parser = this.serialPort.pipe(
new SerialPort.parsers.Delimiter(
new DelimiterParser(
{delimiter: [ZiGateFrame.STOP_BYTE], includeDelimiter: true}
),
);
Expand Down Expand Up @@ -251,7 +253,7 @@ export default class ZiGate extends EventEmitter {


this.parser = this.socketPort.pipe(
new SerialPort.parsers.Delimiter({delimiter: [ZiGateFrame.STOP_BYTE], includeDelimiter: true}),
new DelimiterParser({delimiter: [ZiGateFrame.STOP_BYTE], includeDelimiter: true}),
);
this.parser.on('data', this.onSerialData.bind(this));

Expand Down
49 changes: 23 additions & 26 deletions test/adapter/z-stack/znp.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "regenerator-runtime/runtime";
import {Znp, ZpiObject} from '../../../src/adapter/z-stack/znp';
import SerialPort from 'serialport';
import {SerialPort} from 'serialport';
import net from 'net';
import {Frame as UnpiFrame, Constants as UnpiConstants} from '../../../src/adapter/z-stack/unpi';
import {duplicateArray, ieeeaAddr1, ieeeaAddr2} from '../../testUtils';
Expand All @@ -22,21 +22,23 @@ jest.mock('../../../src/utils/wait', () => {
});

jest.mock('serialport', () => {
return jest.fn().mockImplementation(() => {
return {
close: mockSerialPortClose,
constructor: mockSerialPortConstructor,
emit: () => {},
on: () => {},
once: mockSerialPortOnce,
open: mockSerialPortOpen,
pipe: mockSerialPortPipe,
set: mockSerialPortSet,
write: mockSerialPortWrite,
flush: mockSerialPortFlush,
isOpen: mockSerialPortIsOpen,
};
});
return {
SerialPort: jest.fn().mockImplementation(() => {
return {
close: mockSerialPortClose,
constructor: mockSerialPortConstructor,
emit: () => {},
on: () => {},
once: mockSerialPortOnce,
open: mockSerialPortOpen,
pipe: mockSerialPortPipe,
set: mockSerialPortSet,
write: mockSerialPortWrite,
flush: mockSerialPortFlush,
isOpen: mockSerialPortIsOpen,
};
}),
};
});

const mockSocketSetNoDelay = jest.fn();
Expand Down Expand Up @@ -141,8 +143,7 @@ describe('ZNP', () => {

expect(SerialPort).toHaveBeenCalledTimes(1);
expect(SerialPort).toHaveBeenCalledWith(
"/dev/ttyACM0",
{"autoOpen": false, "baudRate": 100, "rtscts": true},
{"path":"/dev/ttyACM0","autoOpen": false, "baudRate": 100, "rtscts": true},
);

expect(mockSerialPortPipe).toHaveBeenCalledTimes(1);
Expand All @@ -157,8 +158,7 @@ describe('ZNP', () => {

expect(SerialPort).toHaveBeenCalledTimes(1);
expect(SerialPort).toHaveBeenCalledWith(
"/dev/ttyACM0",
{"autoOpen": false, "baudRate": 100, "rtscts": true},
{"path":"/dev/ttyACM0","autoOpen": false, "baudRate": 100, "rtscts": true},
);

expect(mockSerialPortPipe).toHaveBeenCalledTimes(1);
Expand All @@ -174,8 +174,7 @@ describe('ZNP', () => {

expect(SerialPort).toHaveBeenCalledTimes(1);
expect(SerialPort).toHaveBeenCalledWith(
"/dev/ttyACM0",
{"autoOpen": false, "baudRate": 115200, "rtscts": false},
{"path":"/dev/ttyACM0","autoOpen": false, "baudRate": 115200, "rtscts": false},
);

expect(mockSerialPortPipe).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -284,8 +283,7 @@ describe('ZNP', () => {

expect(SerialPort).toHaveBeenCalledTimes(1);
expect(SerialPort).toHaveBeenCalledWith(
"/dev/ttyACM0",
{"autoOpen": false, "baudRate": 100, "rtscts": true},
{"path":"/dev/ttyACM0","autoOpen": false, "baudRate": 100, "rtscts": true},
);

expect(error).toEqual(new Error("Error while opening serialport 'failed!'"));
Expand All @@ -310,8 +308,7 @@ describe('ZNP', () => {

expect(SerialPort).toHaveBeenCalledTimes(1);
expect(SerialPort).toHaveBeenCalledWith(
"/dev/ttyACM0",
{"autoOpen": false, "baudRate": 100, "rtscts": true},
{"path": "/dev/ttyACM0", "autoOpen": false, "baudRate": 100, "rtscts": true},
);

expect(error).toEqual(new Error("Error while opening serialport 'failed!'"));
Expand Down