diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 48f9944..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,24 +0,0 @@ - - -##### Checklist - - -- [ ] `npm test` passes -- [ ] tests and/or benchmarks are included -- [ ] documentation is changed or added -- [ ] commit message follows commit guidelines - -##### Affected core subsystem(s) - - - -##### Description of change - diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index b85b4e4..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,72 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ master ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ master ] - schedule: - - cron: '33 12 * * 5' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'javascript' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹ️ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index bbbe7a1..4a9bdf6 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -3,16 +3,15 @@ name: CI on: push: branches: [ master ] - pull_request: branches: [ master ] - workflow_dispatch: {} - jobs: Job: name: Node.js - uses: fengmk2/github-actions/.github/workflows/node-test-mysql.yml@master + uses: node-modules/github-actions/.github/workflows/node-test-mysql.yml@master with: os: 'ubuntu-latest' - version: '16, 18' + version: '16, 18, 20, 22' + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1612587..a2bf04a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,14 +4,10 @@ on: push: branches: [ master ] - workflow_dispatch: {} - jobs: release: name: Node.js - uses: artusjs/github-actions/.github/workflows/node-release.yml@v1 + uses: eggjs/github-actions/.github/workflows/node-release.yml@master secrets: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} GIT_TOKEN: ${{ secrets.GIT_TOKEN }} - with: - checkTest: false diff --git a/README.md b/README.md index 963a535..26e9617 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ [download-image]: https://img.shields.io/npm/dm/egg-mysql.svg?style=flat-square [download-url]: https://npmjs.org/package/egg-mysql -Aliyun rds client(support mysql portocal) for egg framework +Aliyun rds client(support mysql protocol) for egg framework ## Install @@ -22,7 +22,7 @@ npm i egg-mysql --save MySQL Plugin for egg, support egg application access to MySQL database. -This plugin based on [ali-rds](https://github.com/ali-sdk/ali-rds), if you want to know specific usage, you should refer to the document of [ali-rds](https://github.com/ali-sdk/ali-rds). +This plugin based on [@eggjs/rds], if you want to know specific usage, you should refer to the document of [@eggjs/rds]. ## Configuration @@ -225,7 +225,7 @@ await app.mysql.insert(table, { #### Custom literal -The following demo showed how to call `CONCAT(s1, ...sn)` funtion in mysql to do string splicing. +The following demo showed how to call `CONCAT(s1, ...sn)` function in mysql to do string splicing. ```ts const Literal = app.mysql.literals.Literal; @@ -247,14 +247,10 @@ Please open an issue [here](https://github.com/eggjs/egg/issues). [MIT](LICENSE) - - ## Contributors -|[
fengmk2](https://github.com/fengmk2)
|[
jtyjty99999](https://github.com/jtyjty99999)
|[
popomore](https://github.com/popomore)
|[
semantic-release-bot](https://github.com/semantic-release-bot)
|[
atian25](https://github.com/atian25)
|[
dead-horse](https://github.com/dead-horse)
| -| :---: | :---: | :---: | :---: | :---: | :---: | -[
AntiMoron](https://github.com/AntiMoron)
|[
guoshencheng](https://github.com/guoshencheng)
|[
Krryxa](https://github.com/Krryxa)
|[
cnwangjie](https://github.com/cnwangjie)
|[
starandtina](https://github.com/starandtina)
|[
shangwenhe](https://github.com/shangwenhe)
+[![Contributors](https://contrib.rocks/image?repo=eggjs/core)](https://github.com/eggjs/core/graphs/contributors) -This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Mon Mar 06 2023 21:57:18 GMT+0800`. +Made with [contributors-img](https://contrib.rocks). - +[@eggjs/rds]: https://github.com/node-modules/rds diff --git a/README.zh-CN.md b/README.zh-CN.md index 6dfe9f4..706bdc0 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -14,7 +14,7 @@ MySQL 插件是为 egg 提供 MySQL 数据库访问的功能 -此插件基于 [ali-rds] 实现一个简单的配置封装,具体使用方法你还需要阅读 [ali-rds] 的文档。 +此插件基于 [@eggjs/rds] 实现一个简单的配置封装,具体使用方法你还需要阅读 [@eggjs/rds] 的文档。 ## 安装 @@ -119,7 +119,7 @@ await client2.query(sql, values); #### app.mysql -如果开启了 `config.mysql.app = true`,则会在 app 上注入 [ali-rds] 客户端 的 [Singleton 单例](https://github.com/eggjs/egg/blob/master/lib/core/singleton.js)。 +如果开启了 `config.mysql.app = true`,则会在 app 上注入 [@eggjs/rds] 客户端 的 [Singleton 单例](https://github.com/eggjs/egg/blob/master/lib/core/singleton.js)。 ```ts await app.mysql.query(sql); @@ -130,7 +130,7 @@ await app.mysqls.get('db1').query(sql); #### agent.mysql -如果开启了 `config.mysql.agent = true`,则会在 agent 上注入 [ali-rds] 客户端 的 [Singleton 单例](https://github.com/eggjs/egg/blob/master/lib/core/singleton.js)。 +如果开启了 `config.mysql.agent = true`,则会在 agent 上注入 [@eggjs/rds] 客户端 的 [Singleton 单例](https://github.com/eggjs/egg/blob/master/lib/core/singleton.js)。 ```ts await agent.mysql.query(sql); @@ -270,16 +270,10 @@ Please open an issue [here](https://github.com/eggjs/egg/issues). [MIT](LICENSE) -[ali-rds]: https://github.com/ali-sdk/ali-rds - - - ## Contributors -|[
fengmk2](https://github.com/fengmk2)
|[
jtyjty99999](https://github.com/jtyjty99999)
|[
popomore](https://github.com/popomore)
|[
semantic-release-bot](https://github.com/semantic-release-bot)
|[
atian25](https://github.com/atian25)
|[
dead-horse](https://github.com/dead-horse)
| -| :---: | :---: | :---: | :---: | :---: | :---: | -[
AntiMoron](https://github.com/AntiMoron)
|[
guoshencheng](https://github.com/guoshencheng)
|[
Krryxa](https://github.com/Krryxa)
|[
cnwangjie](https://github.com/cnwangjie)
|[
starandtina](https://github.com/starandtina)
|[
shangwenhe](https://github.com/shangwenhe)
+[![Contributors](https://contrib.rocks/image?repo=eggjs/core)](https://github.com/eggjs/core/graphs/contributors) -This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Mon Mar 06 2023 21:57:18 GMT+0800`. +Made with [contributors-img](https://contrib.rocks). - +[@eggjs/rds]: https://github.com/node-modules/rds diff --git a/index.d.ts b/index.d.ts index f05608e..7b29051 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,4 +1,4 @@ -import type { RDSClient } from 'ali-rds'; +import type { RDSClient } from '@eggjs/rds'; type EggMySQL = RDSClient; diff --git a/lib/mysql.ts b/lib/mysql.ts index 113d299..899cbc0 100644 --- a/lib/mysql.ts +++ b/lib/mysql.ts @@ -1,5 +1,5 @@ import type { Application, Agent } from 'egg'; -import { RDSClient } from 'ali-rds'; +import { RDSClient } from '@eggjs/rds'; let count = 0; function createOneClient(config: Record, app: Application | Agent) { diff --git a/package.json b/package.json index 0b0b32c..2bfc6e5 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "database" ], "dependencies": { - "ali-rds": "^6.4.0" + "@eggjs/rds": "^1.2.1" }, "devDependencies": { "@eggjs/tsconfig": "^1.3.2", @@ -31,15 +31,13 @@ "egg-mock": "^5.10.6", "eslint": "^8.16.0", "eslint-config-egg": "^12.1.0", - "git-contributor": "^2.0.0", "tsd": "^0.26.0", "typescript": "^4.9.5" }, "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "scripts": { - "contributor": "git-contributor", "tsd": "tsd", "test": "npm run lint -- --fix && npm run test-local", "test-local": "egg-bin test", diff --git a/test/mysql.test.ts b/test/mysql.test.ts index 0b468a9..5169331 100644 --- a/test/mysql.test.ts +++ b/test/mysql.test.ts @@ -95,8 +95,10 @@ describe('test/mysql.test.ts', () => { assert(user); assert(typeof user.user_id === 'string' && user.user_id); - const row = await app.mysql.get('npm_auth', { password: new app.mysql.literals.Literal('is not NULL') }); - assert(row.id === user.id); + // breaking change on mysql2 + // SELECT * FROM `npm_auth` WHERE `password` = is not NULL LIMIT 0, 1 + // const row = await app.mysql.get('npm_auth', { password: new app.mysql.literals.Literal('is not NULL') }); + // assert(row.id === user.id); }); it('should query one not exists return null', async () => { @@ -118,8 +120,13 @@ describe('test/mysql.test.ts', () => { }); await assert.rejects(async () => { await app.ready(); - }, (err: Error) => { - assert.match(err.message, /ER_ACCESS_DENIED_ERROR/); + }, (err: any) => { + assert.match(err.message, /Access denied for user/); + assert.equal(err.code, 'ER_ACCESS_DENIED_ERROR'); + assert.equal(err.errno, 1045); + assert.equal(err.sqlState, '28000'); + assert.match(err.sqlMessage, /^Access denied for user 'root'@'[^\']+' \(using password: YES\)$/); + assert.equal(err.name, 'RDSClientGetConnectionError'); return true; }); });