Skip to content

Commit 1b129e8

Browse files
authored
feat: upgrade ali-rds v4 (#24)
1 parent 686457b commit 1b129e8

File tree

5 files changed

+27
-13
lines changed

5 files changed

+27
-13
lines changed

.github/workflows/nodejs.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
uses: actions/checkout@v2
4141

4242
- name: Use Node.js ${{ matrix.node-version }}
43-
uses: actions/setup-node@v1
43+
uses: actions/setup-node@v3
4444
with:
4545
node-version: ${{ matrix.node-version }}
4646

@@ -51,6 +51,6 @@ jobs:
5151
run: npm run ci
5252

5353
- name: Code Coverage
54-
uses: codecov/codecov-action@v1
54+
uses: codecov/codecov-action@v3
5555
with:
5656
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/release.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
7+
workflow_dispatch: {}
8+
9+
jobs:
10+
release:
11+
name: Node.js
12+
uses: artusjs/github-actions/.github/workflows/node-release.yml@v1
13+
secrets:
14+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
15+
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
16+
with:
17+
checkTest: false

lib/mysql.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
'use strict';
2-
3-
const rds = require('ali-rds');
1+
const RDSClient = require('ali-rds');
42

53
let count = 0;
64

@@ -11,12 +9,13 @@ module.exports = app => {
119
function createOneClient(config, app) {
1210
app.coreLogger.info('[egg-mysql] connecting %s@%s:%s/%s',
1311
config.user, config.host, config.port, config.database);
14-
const client = rds(config);
12+
const client = new RDSClient(config);
1513

1614
app.beforeStart(async () => {
1715
const rows = await client.query('select now() as currentTime;');
1816
const index = count++;
19-
app.coreLogger.info(`[egg-mysql] instance[${index}] status OK, rds currentTime: ${rows[0].currentTime}`);
17+
app.coreLogger.info('[egg-mysql] instance[%s] status OK, rds currentTime: %s',
18+
index, rows[0].currentTime);
2019
});
2120
return client;
2221
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"database"
2121
],
2222
"dependencies": {
23-
"ali-rds": "^3.4.0"
23+
"ali-rds": "^4.0.1"
2424
},
2525
"devDependencies": {
2626
"egg": "^3.5.0",

test/mysql.test.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ describe('test/mysql.test.js', () => {
3434
await app.mysql.query(`delete from npm_auth where user_id like 'egg-${uid}%'`);
3535
});
3636

37-
after(done => {
38-
app.mysql.end(err => {
39-
app.close();
40-
done(err);
41-
});
37+
after(async () => {
38+
await app.mysql.end();
39+
await app.close();
4240
});
4341

4442
afterEach(mm.restore);

0 commit comments

Comments
 (0)