From 25cfd0e6f9100bffa29b90483902aa2a51ab82c8 Mon Sep 17 00:00:00 2001 From: leibale Date: Wed, 12 May 2021 19:16:17 -0400 Subject: [PATCH] add tests coverage report --- .gitignore | 2 +- .nycrc.json | 4 + lib/client.spec.ts | 4 +- lib/client.ts | 10 +- lib/cluster-slots.ts | 8 +- lib/cluster.spec.ts | 2 +- lib/cluster.ts | 11 +- lib/commands/APPEND.spec.ts | 2 +- lib/commands/APPEND.ts | 2 +- lib/commands/AUTH.spec.ts | 2 +- lib/commands/AUTH.ts | 2 +- lib/commands/CLUSTER_NODES.spec.ts | 2 +- lib/commands/COPY.spec.ts | 4 +- lib/commands/COPY.ts | 2 +- lib/commands/DECR.spec.ts | 4 +- lib/commands/DECR.ts | 2 +- lib/commands/DECRBY.spec.ts | 4 +- lib/commands/DECRBY.ts | 2 +- lib/commands/DEL.spec.ts | 4 +- lib/commands/DEL.ts | 2 +- lib/commands/DUMP.spec.ts | 2 +- lib/commands/DUMP.ts | 2 +- lib/commands/EXISTS.ts | 2 +- lib/commands/EXPIRE.ts | 2 +- lib/commands/EXPIREAT.ts | 2 +- lib/commands/FLUSHALL.ts | 2 +- lib/commands/GET.ts | 2 +- lib/commands/HDEL.ts | 2 +- lib/commands/HELLO.spec.ts | 2 +- lib/commands/HELLO.ts | 2 +- lib/commands/HEXISTS.ts | 2 +- lib/commands/HGETALL.spec.ts | 2 +- lib/commands/HINCRBY.ts | 2 +- lib/commands/HINCRBYFLOAT.ts | 2 +- lib/commands/HLEN.ts | 2 +- lib/commands/HSET.ts | 2 +- lib/commands/INCR.ts | 2 +- lib/commands/INCRBY.ts | 2 +- lib/commands/INCRBYFLOAT.ts | 2 +- lib/commands/KEYS.spec.ts | 2 +- lib/commands/PING.spec.ts | 2 +- lib/commands/PING.ts | 2 +- lib/commands/SET.spec.ts | 4 +- lib/commands/client.ts | 2 +- lib/commands/cluster.ts | 2 +- lib/commands/index.ts | 58 ++++----- lib/multi-command.spec.ts | 4 +- lib/multi-command.ts | 6 +- lib/socket.ts | 1 + lib/test-utils.ts | 6 +- package-lock.json | 185 +++++++++++++++++++++++++++++ package.json | 4 +- tsconfig.json | 11 +- tsconfig.spec.json | 8 -- 54 files changed, 299 insertions(+), 111 deletions(-) create mode 100644 .nycrc.json delete mode 100644 tsconfig.spec.json diff --git a/.gitignore b/.gitignore index 3f6f84ab82..e0d5c3ed30 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,6 @@ node_modules dist .nyc_output -.nycrc.json +coverage benchmark dump.rdb \ No newline at end of file diff --git a/.nycrc.json b/.nycrc.json new file mode 100644 index 0000000000..2a9edeab23 --- /dev/null +++ b/.nycrc.json @@ -0,0 +1,4 @@ +{ + "extends": "@istanbuljs/nyc-config-typescript", + "exclude": ["./**/*.spec.ts", "./lib/test-utils.ts"] +} \ No newline at end of file diff --git a/lib/client.spec.ts b/lib/client.spec.ts index c129f46c01..73a1773bb2 100644 --- a/lib/client.spec.ts +++ b/lib/client.spec.ts @@ -1,6 +1,6 @@ import { strict as assert } from 'assert'; -import { TestRedisServers, TEST_REDIS_SERVERS, itWithClient } from './test-utils.js'; -import RedisClient from './client.js'; +import { TestRedisServers, TEST_REDIS_SERVERS, itWithClient } from './test-utils'; +import RedisClient from './client'; describe('Client', () => { describe('authentication', () => { diff --git a/lib/client.ts b/lib/client.ts index d91c4de5b8..8aa9274a48 100644 --- a/lib/client.ts +++ b/lib/client.ts @@ -1,8 +1,8 @@ -import RedisSocket, { RedisSocketOptions } from './socket.js'; -import RedisCommandsQueue, { AddCommandOptions } from './commands-queue.js'; -import COMMANDS from './commands/client.js'; -import { RedisCommand, RedisModules, RedisModule, RedisReply } from './commands/index.js'; -import RedisMultiCommand, { MultiQueuedCommand, RedisMultiCommandType } from './multi-command.js'; +import RedisSocket, { RedisSocketOptions } from './socket'; +import RedisCommandsQueue, { AddCommandOptions } from './commands-queue'; +import COMMANDS from './commands/client'; +import { RedisCommand, RedisModules, RedisModule, RedisReply } from './commands'; +import RedisMultiCommand, { MultiQueuedCommand, RedisMultiCommandType } from './multi-command'; import EventEmitter from 'events'; export interface RedisClientOptions { diff --git a/lib/cluster-slots.ts b/lib/cluster-slots.ts index f4f6515c39..243b8609fb 100644 --- a/lib/cluster-slots.ts +++ b/lib/cluster-slots.ts @@ -1,8 +1,8 @@ import calculateSlot from 'cluster-key-slot'; -import RedisClient from './client.js'; -import { RedisSocketOptions } from './socket.js'; -import { RedisClusterNode } from './commands/CLUSTER_NODES.js'; -import { RedisClusterOptions } from './cluster.js'; +import RedisClient from './client'; +import { RedisSocketOptions } from './socket'; +import { RedisClusterNode } from './commands/CLUSTER_NODES'; +import { RedisClusterOptions } from './cluster'; export default class RedisClusterSlots { readonly #options: RedisClusterOptions; diff --git a/lib/cluster.spec.ts b/lib/cluster.spec.ts index 08fd3fca1e..f68215c066 100644 --- a/lib/cluster.spec.ts +++ b/lib/cluster.spec.ts @@ -1,4 +1,4 @@ -import RedisCluster from './cluster.js'; +import RedisCluster from './cluster'; describe.skip('Cluster', () => { it('sendCommand', async () => { diff --git a/lib/cluster.ts b/lib/cluster.ts index c84e287d9e..ab2375e1bf 100644 --- a/lib/cluster.ts +++ b/lib/cluster.ts @@ -1,9 +1,8 @@ -import calculateSlot from 'cluster-key-slot'; -import COMMANDS from './commands/cluster.js'; -import { RedisCommand, RedisModule, RedisModules } from './commands/index.js'; -import { RedisCommandSignature } from './client.js'; -import { RedisSocketOptions } from './socket.js'; -import RedisClusterSlots from './cluster-slots.js'; +import COMMANDS from './commands/cluster'; +import { RedisCommand, RedisModule, RedisModules } from './commands'; +import { RedisCommandSignature } from './client'; +import { RedisSocketOptions } from './socket'; +import RedisClusterSlots from './cluster-slots'; export interface RedisClusterOptions { rootNodes: Array; diff --git a/lib/commands/APPEND.spec.ts b/lib/commands/APPEND.spec.ts index b3d774f38f..283ab80795 100644 --- a/lib/commands/APPEND.spec.ts +++ b/lib/commands/APPEND.spec.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'assert'; -import { transformArguments } from './APPEND.js'; +import { transformArguments } from './APPEND'; describe('AUTH', () => { it('transformArguments', () => { diff --git a/lib/commands/APPEND.ts b/lib/commands/APPEND.ts index b012623d21..f64e835113 100644 --- a/lib/commands/APPEND.ts +++ b/lib/commands/APPEND.ts @@ -1,4 +1,4 @@ -import { transformReplyString } from './generic-transformers.js'; +import { transformReplyString } from './generic-transformers'; export const FIRST_KEY_INDEX = 1; diff --git a/lib/commands/AUTH.spec.ts b/lib/commands/AUTH.spec.ts index 019e672745..1907488346 100644 --- a/lib/commands/AUTH.spec.ts +++ b/lib/commands/AUTH.spec.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'assert'; -import { transformArguments } from './AUTH.js'; +import { transformArguments } from './AUTH'; describe('AUTH', () => { describe('transformArguments', () => { diff --git a/lib/commands/AUTH.ts b/lib/commands/AUTH.ts index eb9e27ae15..750f0f5435 100644 --- a/lib/commands/AUTH.ts +++ b/lib/commands/AUTH.ts @@ -1,4 +1,4 @@ -import { transformReplyString } from './generic-transformers.js'; +import { transformReplyString } from './generic-transformers'; export interface AuthOptions { username?: string; diff --git a/lib/commands/CLUSTER_NODES.spec.ts b/lib/commands/CLUSTER_NODES.spec.ts index ef2c267d9c..4fb2767918 100644 --- a/lib/commands/CLUSTER_NODES.spec.ts +++ b/lib/commands/CLUSTER_NODES.spec.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'assert'; -import { RedisClusterNodeLinkStates, transformArguments, transformReply } from './CLUSTER_NODES.js'; +import { RedisClusterNodeLinkStates, transformArguments, transformReply } from './CLUSTER_NODES'; describe('CLUSTER NODES', () => { it('transformArguments', () => { diff --git a/lib/commands/COPY.spec.ts b/lib/commands/COPY.spec.ts index bc0567d366..fe2930f6cc 100644 --- a/lib/commands/COPY.spec.ts +++ b/lib/commands/COPY.spec.ts @@ -1,6 +1,6 @@ import { strict as assert } from 'assert'; -import { TestRedisServers, itWithClient } from '../test-utils.js'; -import { transformArguments, transformReply } from './COPY.js'; +import { TestRedisServers, itWithClient } from '../test-utils'; +import { transformArguments, transformReply } from './COPY'; describe('COPY', () => { describe('transformArguments', () => { diff --git a/lib/commands/COPY.ts b/lib/commands/COPY.ts index f93edab4f8..534b0d9c48 100644 --- a/lib/commands/COPY.ts +++ b/lib/commands/COPY.ts @@ -1,4 +1,4 @@ -import { transformReplyBoolean } from './generic-transformers.js'; +import { transformReplyBoolean } from './generic-transformers'; interface CopyCommandOptions { destinationDb?: number; diff --git a/lib/commands/DECR.spec.ts b/lib/commands/DECR.spec.ts index a9eae76f5f..5b4b4f0fd3 100644 --- a/lib/commands/DECR.spec.ts +++ b/lib/commands/DECR.spec.ts @@ -1,6 +1,6 @@ import { strict as assert } from 'assert'; -import { TestRedisServers, itWithClient } from '../test-utils.js'; -import { transformArguments } from './DECR.js'; +import { TestRedisServers, itWithClient } from '../test-utils'; +import { transformArguments } from './DECR'; describe('DECR', () => { it('transformArguments', () => { diff --git a/lib/commands/DECR.ts b/lib/commands/DECR.ts index 6aa4f3b16e..cac6e07f05 100644 --- a/lib/commands/DECR.ts +++ b/lib/commands/DECR.ts @@ -1,4 +1,4 @@ -import { transformReplyNumber } from './generic-transformers.js'; +import { transformReplyNumber } from './generic-transformers'; export const FIRST_KEY_INDEX = 1; diff --git a/lib/commands/DECRBY.spec.ts b/lib/commands/DECRBY.spec.ts index c8bde40f46..1c9ac69bb9 100644 --- a/lib/commands/DECRBY.spec.ts +++ b/lib/commands/DECRBY.spec.ts @@ -1,6 +1,6 @@ import { strict as assert } from 'assert'; -import { TestRedisServers, itWithClient } from '../test-utils.js'; -import { transformArguments } from './DECRBY.js'; +import { TestRedisServers, itWithClient } from '../test-utils'; +import { transformArguments } from './DECRBY'; describe('DECRBY', () => { it('transformArguments', () => { diff --git a/lib/commands/DECRBY.ts b/lib/commands/DECRBY.ts index ab42660ba4..cc163cbe82 100644 --- a/lib/commands/DECRBY.ts +++ b/lib/commands/DECRBY.ts @@ -1,4 +1,4 @@ -import { transformReplyNumber } from './generic-transformers.js'; +import { transformReplyNumber } from './generic-transformers'; export const FIRST_KEY_INDEX = 1; diff --git a/lib/commands/DEL.spec.ts b/lib/commands/DEL.spec.ts index 6533e9c25e..6124c97897 100644 --- a/lib/commands/DEL.spec.ts +++ b/lib/commands/DEL.spec.ts @@ -1,6 +1,6 @@ import { strict as assert } from 'assert'; -import { TestRedisServers, itWithClient } from '../test-utils.js'; -import { transformArguments } from './DEL.js'; +import { TestRedisServers, itWithClient } from '../test-utils'; +import { transformArguments } from './DEL'; describe('DEL', () => { describe('transformArguments', () => { diff --git a/lib/commands/DEL.ts b/lib/commands/DEL.ts index 8f7c517aaa..c4dd6e73ad 100644 --- a/lib/commands/DEL.ts +++ b/lib/commands/DEL.ts @@ -1,4 +1,4 @@ -import { transformReplyNumber } from './generic-transformers.js'; +import { transformReplyNumber } from './generic-transformers'; export function transformArguments(...keys: Array): Array { return ['DEL', ...keys]; diff --git a/lib/commands/DUMP.spec.ts b/lib/commands/DUMP.spec.ts index 397e404f45..e3f42c5757 100644 --- a/lib/commands/DUMP.spec.ts +++ b/lib/commands/DUMP.spec.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'assert'; -import { TestRedisServers, itWithClient } from '../test-utils.js'; +import { TestRedisServers, itWithClient } from '../test-utils'; describe('DUMP', () => { itWithClient(TestRedisServers.OPEN, 'client.dump', async client => { diff --git a/lib/commands/DUMP.ts b/lib/commands/DUMP.ts index 197f0680d7..1c72110f21 100644 --- a/lib/commands/DUMP.ts +++ b/lib/commands/DUMP.ts @@ -1,4 +1,4 @@ -import { transformReplyString } from './generic-transformers.js'; +import { transformReplyString } from './generic-transformers'; export function transformArguments(key: string): Array { return ['DUMP', key]; diff --git a/lib/commands/EXISTS.ts b/lib/commands/EXISTS.ts index fff00982ec..ce26d20164 100644 --- a/lib/commands/EXISTS.ts +++ b/lib/commands/EXISTS.ts @@ -1,4 +1,4 @@ -import { transformReplyBoolean } from './generic-transformers.js'; +import { transformReplyBoolean } from './generic-transformers'; export function transformArguments(...keys: Array): Array { return ['EXISTS', ...keys]; diff --git a/lib/commands/EXPIRE.ts b/lib/commands/EXPIRE.ts index 42c894f006..04b0504a6f 100644 --- a/lib/commands/EXPIRE.ts +++ b/lib/commands/EXPIRE.ts @@ -1,4 +1,4 @@ -import { transformReplyBoolean } from './generic-transformers.js'; +import { transformReplyBoolean } from './generic-transformers'; export function transformArguments(key: string, seconds: number): Array { return ['EXPIRE', key, seconds.toString()]; diff --git a/lib/commands/EXPIREAT.ts b/lib/commands/EXPIREAT.ts index 9094645e87..35f9fad11b 100644 --- a/lib/commands/EXPIREAT.ts +++ b/lib/commands/EXPIREAT.ts @@ -1,4 +1,4 @@ -import { transformReplyBoolean } from './generic-transformers.js'; +import { transformReplyBoolean } from './generic-transformers'; export function transformArguments(key: string, timestamp: Date | number): Array { return [ diff --git a/lib/commands/FLUSHALL.ts b/lib/commands/FLUSHALL.ts index b45ae3498d..4b058ca5e6 100644 --- a/lib/commands/FLUSHALL.ts +++ b/lib/commands/FLUSHALL.ts @@ -1,4 +1,4 @@ -import { transformReplyString } from './generic-transformers.js'; +import { transformReplyString } from './generic-transformers'; enum RedisFlushModes { ASYNC = 'ASYNC', diff --git a/lib/commands/GET.ts b/lib/commands/GET.ts index 74c9f6c620..2ed1c0dc36 100644 --- a/lib/commands/GET.ts +++ b/lib/commands/GET.ts @@ -1,4 +1,4 @@ -import { transformReplyString } from './generic-transformers.js'; +import { transformReplyString } from './generic-transformers'; export const FIRST_KEY_INDEX = 1; diff --git a/lib/commands/HDEL.ts b/lib/commands/HDEL.ts index c9d492197b..f12fcd7f28 100644 --- a/lib/commands/HDEL.ts +++ b/lib/commands/HDEL.ts @@ -1,4 +1,4 @@ -import { transformReplyNumber } from './generic-transformers.js'; +import { transformReplyNumber } from './generic-transformers'; export const FIRST_KEY_INDEX = 1; diff --git a/lib/commands/HELLO.spec.ts b/lib/commands/HELLO.spec.ts index 4537552f5f..76b2579506 100644 --- a/lib/commands/HELLO.spec.ts +++ b/lib/commands/HELLO.spec.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'assert'; -import { transformArguments } from './HELLO.js'; +import { transformArguments } from './HELLO'; describe('HELLO', () => { describe('transformArguments', () => { diff --git a/lib/commands/HELLO.ts b/lib/commands/HELLO.ts index cb0c4161e9..33984ec365 100644 --- a/lib/commands/HELLO.ts +++ b/lib/commands/HELLO.ts @@ -1,4 +1,4 @@ -import { AuthOptions, transformArguments as transformAuthArguments } from './AUTH.js'; +import { AuthOptions, transformArguments as transformAuthArguments } from './AUTH'; export function transformArguments(protover?: number, auth?: AuthOptions): Array { const args = ['HELLO']; diff --git a/lib/commands/HEXISTS.ts b/lib/commands/HEXISTS.ts index 631b7286eb..7cf0b158d9 100644 --- a/lib/commands/HEXISTS.ts +++ b/lib/commands/HEXISTS.ts @@ -1,4 +1,4 @@ -import { transformReplyBoolean } from './generic-transformers.js'; +import { transformReplyBoolean } from './generic-transformers'; export const FIRST_KEY_INDEX = 1; diff --git a/lib/commands/HGETALL.spec.ts b/lib/commands/HGETALL.spec.ts index 78ac479704..a0ac1b2674 100644 --- a/lib/commands/HGETALL.spec.ts +++ b/lib/commands/HGETALL.spec.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'assert'; -import { transformReply } from './HGETALL.js'; +import { transformReply } from './HGETALL'; describe('HGETALL', () => { describe('transformReply', () => { diff --git a/lib/commands/HINCRBY.ts b/lib/commands/HINCRBY.ts index e0f3484a1f..192dac456e 100644 --- a/lib/commands/HINCRBY.ts +++ b/lib/commands/HINCRBY.ts @@ -1,4 +1,4 @@ -import { transformReplyNumber } from './generic-transformers.js'; +import { transformReplyNumber } from './generic-transformers'; export const FIRST_KEY_INDEX = 1; diff --git a/lib/commands/HINCRBYFLOAT.ts b/lib/commands/HINCRBYFLOAT.ts index 092bc4da9c..10c949b8d9 100644 --- a/lib/commands/HINCRBYFLOAT.ts +++ b/lib/commands/HINCRBYFLOAT.ts @@ -1,4 +1,4 @@ -import { transformReplyNumber } from './generic-transformers.js'; +import { transformReplyNumber } from './generic-transformers'; export const FIRST_KEY_INDEX = 1; diff --git a/lib/commands/HLEN.ts b/lib/commands/HLEN.ts index e04f395e68..ba7ccc3aed 100644 --- a/lib/commands/HLEN.ts +++ b/lib/commands/HLEN.ts @@ -1,4 +1,4 @@ -import { transformReplyNumber } from './generic-transformers.js'; +import { transformReplyNumber } from './generic-transformers'; export const FIRST_KEY_INDEX = 1; diff --git a/lib/commands/HSET.ts b/lib/commands/HSET.ts index 70c24f476a..7b09a999d7 100644 --- a/lib/commands/HSET.ts +++ b/lib/commands/HSET.ts @@ -1,4 +1,4 @@ -import { transformReplyString } from './generic-transformers.js'; +import { transformReplyString } from './generic-transformers'; type HSETObject = Record; diff --git a/lib/commands/INCR.ts b/lib/commands/INCR.ts index 350a083b5a..00747f0f7e 100644 --- a/lib/commands/INCR.ts +++ b/lib/commands/INCR.ts @@ -1,4 +1,4 @@ -import { transformReplyNumber } from './generic-transformers.js'; +import { transformReplyNumber } from './generic-transformers'; export const FIRST_KEY_INDEX = 1; diff --git a/lib/commands/INCRBY.ts b/lib/commands/INCRBY.ts index d48a7c4f94..8fd31d0338 100644 --- a/lib/commands/INCRBY.ts +++ b/lib/commands/INCRBY.ts @@ -1,4 +1,4 @@ -import { transformReplyNumber } from './generic-transformers.js'; +import { transformReplyNumber } from './generic-transformers'; export const FIRST_KEY_INDEX = 1; diff --git a/lib/commands/INCRBYFLOAT.ts b/lib/commands/INCRBYFLOAT.ts index c5c626e609..1de9f08dd2 100644 --- a/lib/commands/INCRBYFLOAT.ts +++ b/lib/commands/INCRBYFLOAT.ts @@ -1,4 +1,4 @@ -import { transformReplyNumber } from './generic-transformers.js'; +import { transformReplyNumber } from './generic-transformers'; export const FIRST_KEY_INDEX = 1; diff --git a/lib/commands/KEYS.spec.ts b/lib/commands/KEYS.spec.ts index 0335e03a0d..d11e8a0f58 100644 --- a/lib/commands/KEYS.spec.ts +++ b/lib/commands/KEYS.spec.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'assert'; -import { TestRedisServers, itWithClient } from '../test-utils.js'; +import { TestRedisServers, itWithClient } from '../test-utils'; describe('KEYS', () => { itWithClient(TestRedisServers.OPEN, 'client.keys', async client => { diff --git a/lib/commands/PING.spec.ts b/lib/commands/PING.spec.ts index 58d983ee16..43b683f192 100644 --- a/lib/commands/PING.spec.ts +++ b/lib/commands/PING.spec.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'assert'; -import { TestRedisServers, itWithClient } from '../test-utils.js'; +import { TestRedisServers, itWithClient } from '../test-utils'; describe('PING', () => { itWithClient(TestRedisServers.OPEN, 'client.ping', async client => { diff --git a/lib/commands/PING.ts b/lib/commands/PING.ts index f8f8048fa4..36e92a08cf 100644 --- a/lib/commands/PING.ts +++ b/lib/commands/PING.ts @@ -1,4 +1,4 @@ -import { transformReplyString } from './generic-transformers.js'; +import { transformReplyString } from './generic-transformers'; export function transformArguments(): Array { return ['PING']; diff --git a/lib/commands/SET.spec.ts b/lib/commands/SET.spec.ts index bb364acd57..8515950fd3 100644 --- a/lib/commands/SET.spec.ts +++ b/lib/commands/SET.spec.ts @@ -1,6 +1,6 @@ import { strict as assert } from 'assert'; -import { TestRedisServers, itWithClient } from '../test-utils.js'; -import { transformArguments } from './SET.js'; +import { TestRedisServers, itWithClient } from '../test-utils'; +import { transformArguments } from './SET'; describe('SET', () => { describe('transformArguments', () => { diff --git a/lib/commands/client.ts b/lib/commands/client.ts index de006a4211..0c52f11e3a 100644 --- a/lib/commands/client.ts +++ b/lib/commands/client.ts @@ -1,4 +1,4 @@ -import COMMON_COMMANDS from './index.js'; +import COMMON_COMMANDS from './index'; export default { ...COMMON_COMMANDS diff --git a/lib/commands/cluster.ts b/lib/commands/cluster.ts index de006a4211..0c52f11e3a 100644 --- a/lib/commands/cluster.ts +++ b/lib/commands/cluster.ts @@ -1,4 +1,4 @@ -import COMMON_COMMANDS from './index.js'; +import COMMON_COMMANDS from './index'; export default { ...COMMON_COMMANDS diff --git a/lib/commands/index.ts b/lib/commands/index.ts index ad66f8a0a1..8a74a3e096 100644 --- a/lib/commands/index.ts +++ b/lib/commands/index.ts @@ -1,32 +1,32 @@ -import * as APPEND from './APPEND.js'; -import * as AUTH from './AUTH.js'; -import * as CLUSTER_NODES from './CLUSTER_NODES.js'; -import * as COPY from './COPY.js'; -import * as DECR from './DECR.js'; -import * as DECRBY from './DECRBY.js'; -import * as DEL from './DEL.js'; -import * as DUMP from './DUMP.js'; -import * as EXISTS from './EXISTS.js'; -import * as EXPIRE from './EXPIRE.js'; -import * as EXPIREAT from './EXPIREAT.js'; -import * as FLUSHALL from './FLUSHALL.js'; -import * as GET from './GET.js'; -import * as HDEL from './HDEL.js'; -import * as HEXISTS from './HEXISTS.js'; -import * as HGET from './HGET.js'; -import * as HGETALL from './HGETALL.js'; -import * as HINCRBY from './HINCRBY.js'; -import * as HINCRBYFLOAT from './HINCRBYFLOAT.js'; -import * as HKEYS from './HKEYS.js'; -import * as HLEN from './HLEN.js'; -import * as HSET from './HSET.js'; -import * as HVALS from './HVALS.js'; -import * as INCR from './INCR.js'; -import * as INCRBY from './INCRBY.js'; -import * as INCRBYFLOAT from './INCRBYFLOAT.js'; -import * as KEYS from './KEYS.js'; -import * as PING from './PING.js'; -import * as SET from './SET.js'; +import * as APPEND from './APPEND'; +import * as AUTH from './AUTH'; +import * as CLUSTER_NODES from './CLUSTER_NODES'; +import * as COPY from './COPY'; +import * as DECR from './DECR'; +import * as DECRBY from './DECRBY'; +import * as DEL from './DEL'; +import * as DUMP from './DUMP'; +import * as EXISTS from './EXISTS'; +import * as EXPIRE from './EXPIRE'; +import * as EXPIREAT from './EXPIREAT'; +import * as FLUSHALL from './FLUSHALL'; +import * as GET from './GET'; +import * as HDEL from './HDEL'; +import * as HEXISTS from './HEXISTS'; +import * as HGET from './HGET'; +import * as HGETALL from './HGETALL'; +import * as HINCRBY from './HINCRBY'; +import * as HINCRBYFLOAT from './HINCRBYFLOAT'; +import * as HKEYS from './HKEYS'; +import * as HLEN from './HLEN'; +import * as HSET from './HSET'; +import * as HVALS from './HVALS'; +import * as INCR from './INCR'; +import * as INCRBY from './INCRBY'; +import * as INCRBYFLOAT from './INCRBYFLOAT'; +import * as KEYS from './KEYS'; +import * as PING from './PING'; +import * as SET from './SET'; export default { APPEND, diff --git a/lib/multi-command.spec.ts b/lib/multi-command.spec.ts index d4128f28ad..1a9d37b9b9 100644 --- a/lib/multi-command.spec.ts +++ b/lib/multi-command.spec.ts @@ -1,6 +1,6 @@ import { strict as assert } from 'assert'; -import RedisMultiCommand, { MultiQueuedCommand } from './multi-command.js'; -import RedisClient from './client.js'; +import RedisMultiCommand, { MultiQueuedCommand } from './multi-command'; +import RedisClient from './client'; describe('Multi Command', () => { it('create', async () => { diff --git a/lib/multi-command.ts b/lib/multi-command.ts index b168524e37..054f6bb41f 100644 --- a/lib/multi-command.ts +++ b/lib/multi-command.ts @@ -1,6 +1,6 @@ -import COMMANDS from './commands/client.js'; -import { RedisCommand, RedisModule, RedisModules, RedisReply } from './commands/index.js'; -import RedisCommandsQueue from './commands-queue.js'; +import COMMANDS from './commands/client'; +import { RedisCommand, RedisModule, RedisModules, RedisReply } from './commands'; +import RedisCommandsQueue from './commands-queue'; type RedisMultiCommandSignature = (...args: Parameters) => RedisMultiCommandType; diff --git a/lib/socket.ts b/lib/socket.ts index 8df7d1f097..a34c7cd86f 100644 --- a/lib/socket.ts +++ b/lib/socket.ts @@ -163,6 +163,7 @@ export default class RedisSocket extends EventEmitter { await this.#retryConnection(0); } catch (err) { this.emit('error', err); + this.#socket = undefined; } } diff --git a/lib/test-utils.ts b/lib/test-utils.ts index 6b4740c551..56fdaa8019 100644 --- a/lib/test-utils.ts +++ b/lib/test-utils.ts @@ -1,9 +1,9 @@ -import RedisClient, { RedisClientOptions, RedisClientType } from './client.js'; -import { RedisModules } from './commands/index.js'; +import RedisClient, { RedisClientType } from './client'; +import { RedisModules } from './commands'; import { spawn } from 'child_process'; import { once } from 'events'; import tcpPortUsed from 'tcp-port-used'; -import { RedisSocketOptions } from './socket.js'; +import { RedisSocketOptions } from './socket'; export enum TestRedisServers { OPEN, diff --git a/package-lock.json b/package-lock.json index c40cbe11f0..6bcaa596e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "yallist": "4.0.0" }, "devDependencies": { + "@istanbuljs/nyc-config-typescript": "^1.0.1", "@types/mocha": "^8.2.2", "@types/node": "^15.0.2", "@types/tcp-port-used": "^1.0.0", @@ -21,6 +22,7 @@ "mocha": "^8.4.0", "nyc": "^15.1.0", "tcp-port-used": "^1.0.2", + "ts-node": "^9.1.1", "typescript": "^4.3.0-beta" }, "engines": { @@ -439,6 +441,23 @@ "node": ">=8" } }, + "node_modules/@istanbuljs/nyc-config-typescript": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@istanbuljs/nyc-config-typescript/-/nyc-config-typescript-1.0.1.tgz", + "integrity": "sha512-/gz6LgVpky205LuoOfwEZmnUtaSmdk0QIMcNFj9OvxhiMhPpKftMgZmGN7jNj7jR+lr8IB1Yks3QSSSNSxfoaQ==", + "dev": true, + "dependencies": { + "@istanbuljs/schema": "^0.1.2" + }, + "engines": { + "node": ">=8" + }, + "peerDependencies": { + "nyc": ">=15", + "source-map-support": "*", + "ts-node": "*" + } + }, "node_modules/@istanbuljs/schema": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", @@ -555,6 +574,12 @@ "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", "dev": true }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -627,6 +652,12 @@ "url": "https://opencollective.com/browserslist" } }, + "node_modules/buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true + }, "node_modules/caching-transform": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", @@ -827,6 +858,12 @@ "safe-buffer": "~5.1.1" } }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -1544,6 +1581,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, "node_modules/minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -2201,6 +2244,25 @@ "node": ">=0.10.0" } }, + "node_modules/source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/source-map-support/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/spawn-wrap": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-2.0.0.tgz", @@ -2330,6 +2392,41 @@ "node": ">=8.0" } }, + "node_modules/ts-node": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-9.1.1.tgz", + "integrity": "sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg==", + "dev": true, + "dependencies": { + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "source-map-support": "^0.5.17", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "typescript": ">=2.7" + } + }, + "node_modules/ts-node/node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/type-fest": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", @@ -2609,6 +2706,15 @@ "node": ">=8" } }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", @@ -2983,6 +3089,15 @@ } } }, + "@istanbuljs/nyc-config-typescript": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@istanbuljs/nyc-config-typescript/-/nyc-config-typescript-1.0.1.tgz", + "integrity": "sha512-/gz6LgVpky205LuoOfwEZmnUtaSmdk0QIMcNFj9OvxhiMhPpKftMgZmGN7jNj7jR+lr8IB1Yks3QSSSNSxfoaQ==", + "dev": true, + "requires": { + "@istanbuljs/schema": "^0.1.2" + } + }, "@istanbuljs/schema": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", @@ -3075,6 +3190,12 @@ "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", "dev": true }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -3131,6 +3252,12 @@ "node-releases": "^1.1.71" } }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true + }, "caching-transform": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", @@ -3290,6 +3417,12 @@ "safe-buffer": "~5.1.1" } }, + "create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -3806,6 +3939,12 @@ "semver": "^6.0.0" } }, + "make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -4306,6 +4445,24 @@ "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", "dev": true }, + "source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, "spawn-wrap": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-2.0.0.tgz", @@ -4402,6 +4559,28 @@ "is-number": "^7.0.0" } }, + "ts-node": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-9.1.1.tgz", + "integrity": "sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg==", + "dev": true, + "requires": { + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "source-map-support": "^0.5.17", + "yn": "3.1.1" + }, + "dependencies": { + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true + } + } + }, "type-fest": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", @@ -4614,6 +4793,12 @@ } } }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true + }, "yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index 3fd87c74ba..ca0e93cf72 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "main": "./dist/index.js", "types": "./dist/index.t.ts", "scripts": { - "test": "tsc -p tsconfig.spec.json && nyc mocha './dist/**/*.spec.js'", + "test": "nyc -r text -r html mocha -r ts-node/register './lib/**/*.spec.ts'", "build": "tsc", "benchmark": "cd ./benchmark && npm run start" }, @@ -33,6 +33,7 @@ "yallist": "4.0.0" }, "devDependencies": { + "@istanbuljs/nyc-config-typescript": "^1.0.1", "@types/mocha": "^8.2.2", "@types/node": "^15.0.2", "@types/tcp-port-used": "^1.0.0", @@ -40,6 +41,7 @@ "mocha": "^8.4.0", "nyc": "^15.1.0", "tcp-port-used": "^1.0.2", + "ts-node": "^9.1.1", "typescript": "^4.3.0-beta" }, "engines": { diff --git a/tsconfig.json b/tsconfig.json index 967d779532..2746cc4e16 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,8 +8,7 @@ "outDir": "./dist", "declaration": true, "useDefineForClassFields": true, - "allowJs": true, - "sourceMap": true + "allowJs": true }, "files": [ "./lib/ts-declarations/cluster-key-slot.d.ts", @@ -18,5 +17,11 @@ "include": [ "./index.ts", "./lib/**/*.ts" - ] + ], + "ts-node": { + "files": true, + "compilerOptions": { + "module": "CommonJS" + } + } } diff --git a/tsconfig.spec.json b/tsconfig.spec.json deleted file mode 100644 index ed8dac1809..0000000000 --- a/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": [ - "./index.ts", - "./lib/**/*.ts", - "./**/*.spec.ts" - ] -}