Skip to content

Commit c558797

Browse files
committed
update packs
1 parent 06ce977 commit c558797

File tree

10 files changed

+968
-978
lines changed

10 files changed

+968
-978
lines changed

.eslintrc.cjs

Lines changed: 0 additions & 54 deletions
This file was deleted.

.eslintrc.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
root: true
2+
env:
3+
es2021: true
4+
node: true
5+
parser: '@babel/eslint-parser'
6+
parserOptions:
7+
ecmaVersion: 12
8+
sourceType: module
9+
extends:
10+
- xo
11+
- plugin:unicorn/recommended
12+
rules:
13+
indent: [error, tab]
14+
linebreak-style: [error, unix]
15+
quotes: [error, single]
16+
semi: [error, never]
17+
semi-spacing:
18+
- error
19+
-
20+
before: false
21+
after: true
22+
no-console: off
23+
no-debugger: off
24+
no-unused-expressions:
25+
- error
26+
-
27+
allowShortCircuit: true
28+
allowTernary: true
29+
allowTaggedTemplates: true
30+
camelcase: off
31+
capitalized-comments: off
32+
spaced-comment: off
33+
padding-line-between-statements: off
34+
no-undef-init: off
35+
unicorn/filename-case: off
36+
unicorn/prevent-abbreviations: off
37+
unicorn/no-reduce: off
38+
unicorn/no-array-reduce: off
39+
# unicorn/no-abusive-eslint-disable: off
40+
# Bug no ctx.body Koa
41+
require-atomic-updates: off

.github/workflows/nodejs.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,23 @@ jobs:
3131
with:
3232
node-version: ${{ matrix.node-version }}
3333

34-
- run: yarn set version berry
35-
- run: >
36-
echo 'nodeLinker: node-modules' >> .yarnrc.yml
37-
- run: yarn cache clean --all
38-
- run: YARN_CHECKSUM_BEHAVIOR=update yarn
39-
- run: npm test
34+
- name: Update yarn
35+
run: yarn set version berry
36+
37+
- name: Log yarn version
38+
run: yarn --version
39+
40+
- name: Generate simple .yarnrc.yml
41+
run: |
42+
echo "nodeLinker: node-modules" >> .yarnrc.yml
43+
44+
- name: Install dependencies
45+
run: yarn install
46+
env:
47+
CI: true
48+
49+
- name: Run test
50+
run: npm test
4051
env:
4152
CI: true
4253
REDIS: 127.0.0.1:${{ job.services.redis.ports[6379] }}

bin/node/prod.js

Lines changed: 0 additions & 45 deletions
This file was deleted.

bin/node/zera renamed to bin/node/zera_npm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

33
DIR="$(cd $(dirname $0) && pwd)"
44
BIN_DIR="$(cd $DIR/.. && pwd)"
@@ -17,10 +17,10 @@ rm -rf \
1717
"${CURR_FOLDER}/.yarn" \
1818
"${CURR_FOLDER}/.pnp.*"
1919

20-
yarn install
20+
npm install
2121

22-
test $? -ne 0 && abort "yarn failed" || ok "zerado..."
22+
test $? -ne 0 && abort "npm failed" || ok "zerado..."
2323

24-
yarn npm audit
24+
npm audit
2525

2626
exit 0

bin/node/zera_yarn

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/sh
2+
3+
DIR="$(cd $(dirname $0) && pwd)"
4+
BIN_DIR="$(cd $DIR/.. && pwd)"
5+
6+
# Import functions
7+
. $BIN_DIR/helper/fn
8+
9+
# Go to current directory
10+
CURR_FOLDER="$(pwd)"
11+
cd $CURR_FOLDER
12+
13+
usage() {
14+
cat <<-EOF
15+
16+
Usage: $0 [options]
17+
18+
Options:
19+
-g Generate .yarnrc.yml
20+
-h Show usage
21+
22+
EOF
23+
exit 0
24+
}
25+
26+
GEN=0
27+
while getopts ":g" opt
28+
do
29+
case ${opt} in
30+
b) GEN=1 ;;
31+
esac
32+
done
33+
34+
rm -rf \
35+
"${CURR_FOLDER}/node_modules" \
36+
"${CURR_FOLDER}/package-lock.json" \
37+
"${CURR_FOLDER}/yarn.lock" \
38+
"${CURR_FOLDER}/.yarn" \
39+
"${CURR_FOLDER}/.pnp.*"
40+
41+
if test "${GEN}" = "1"; then
42+
echo "nodeLinker: node-modules" > "${CURR_FOLDER}/.yarnrc.yml"
43+
fi
44+
45+
yarn install
46+
47+
test $? -ne 0 && abort "yarn failed" || ok "zerado..."
48+
49+
yarn npm audit
50+
51+
exit 0

package.json

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,29 @@
2727
"node": ">=14.16"
2828
},
2929
"scripts": {
30-
"eslint": "eslint --config .eslintrc.cjs --ext .js --ignore-path .gitignore .",
30+
"eslint": "eslint --config .eslintrc.yml --ext .js --ignore-path .gitignore .",
3131
"pretest": "npm run eslint",
32-
"test": "c8 --reporter=text --reporter=lcov ava"
32+
"test": "c8 --reporter=text --reporter=text-summary --reporter=lcov ava --tap"
3333
},
3434
"dependencies": {
35-
"@tadashi/connect-redis": "1.0.1",
36-
"@tadashi/jsonb": "3.1.0"
35+
"@tadashi/connect-redis": "2.1.0",
36+
"@tadashi/jsonb": "4.0.0"
3737
},
3838
"peerDependencies": {
3939
"ioredis": ">= 4.19.4 < 5"
4040
},
4141
"devDependencies": {
42-
"@babel/core": "7.14.6",
43-
"@babel/eslint-parser": "7.14.7",
42+
"@babel/core": "7.15.0",
43+
"@babel/eslint-parser": "7.15.0",
4444
"@babel/plugin-syntax-top-level-await": "7.14.5",
45-
"@babel/preset-env": "7.14.7",
45+
"@babel/preset-env": "7.15.0",
4646
"@tadashi/sleep": "2.0.1",
4747
"ava": "3.15.0",
48-
"c8": "7.7.3",
49-
"eslint": "7.29.0",
50-
"eslint-config-xo": "0.37.0",
51-
"eslint-plugin-unicorn": "33.0.1",
52-
"ioredis": "4.27.6",
53-
"p-event": "4.2.0"
48+
"c8": "7.8.0",
49+
"eslint": "7.32.0",
50+
"eslint-config-xo": "0.38.0",
51+
"eslint-plugin-unicorn": "35.0.0",
52+
"ioredis": "4.27.8"
5453
},
5554
"babel": {
5655
"presets": [

src/cache-redis.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Cache {
1818
options.redis.keyPrefix = `${options.redis.keyPrefix}_${options.namespace}:`
1919

2020
this.namespace = '@ns'
21-
this.redis = connect(addresses, options.redis)
21+
this.redis = connect({...options.redis, addresses})
2222
}
2323

2424
async get(key) {

test/cache-redis.spec.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import test from 'ava'
2-
import pEvent from 'p-event'
32
import sleep from '@tadashi/sleep'
43
import Cache from '../src/cache-redis.js'
54

@@ -123,32 +122,10 @@ test('clear', async t => {
123122
t.is(_clear, undefined)
124123
})
125124

126-
test('error', async t => {
127-
const _g = new Cache({
128-
redis: {
129-
retryStrategy: () => false,
130-
},
131-
addresses: 'xxx',
132-
})
133-
const error = await pEvent(_g.redis, 'error')
134-
t.regex(error.code, /EAI_AGAIN|ENOTFOUND/)
135-
})
136-
137125
test('hash', async t => {
138126
const ts = Date.now()
139127
const _z = new Cache()
140128
await _z.redis.hset('room_id', 'user_id', ts)
141129
const r = await _z.redis.hget('room_id', 'user_id')
142130
t.is(Number(r), ts)
143131
})
144-
145-
test('cluster', async t => {
146-
const _x = new Cache({
147-
redis: {
148-
clusterRetryStrategy: () => false,
149-
},
150-
addresses: '127.0.0.1:6379,127.0.0.1:6379',
151-
})
152-
const error = await pEvent(_x.redis, 'error')
153-
t.is(error.message, 'Failed to refresh slots cache.')
154-
})

0 commit comments

Comments
 (0)