Skip to content

Commit dfdaa74

Browse files
authored
feat: support cjs and esm both by tshy (#33)
BREAKING CHANGE: drop Node.js < 18.19.0 support and only support egg>=4 part of eggjs/egg#3644 eggjs/egg#5257 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Refined MySQL plugin integration with improved lifecycle management and simplified singleton access. - Added a ready-to-use Docker Compose setup for local MySQL development. - **Documentation** - Updated all documentation with the new package name (@eggjs/mysql) and revised usage examples for clarity. - **Chores** - Enhanced package metadata and dependency management. - Updated CI configuration to support Node.js versions 18, 20, and 22. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent c978241 commit dfdaa74

File tree

53 files changed

+828
-399
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+828
-399
lines changed

.eslintignore

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

.eslintrc

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

.github/workflows/nodejs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ name: CI
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88

99
jobs:
1010
Job:
1111
name: Node.js
1212
uses: node-modules/github-actions/.github/workflows/node-test-mysql.yml@master
1313
with:
1414
os: 'ubuntu-latest'
15-
version: '16, 18, 20, 22'
15+
version: '18, 20, 22'
1616
secrets:
1717
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Release
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66

77
jobs:
88
release:

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

.oxlintrc.json

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"env": {
4+
"node": true,
5+
"mocha": true
6+
},
7+
"categories": {
8+
"correctness": "error",
9+
"perf": "error",
10+
"nursery": "error",
11+
"restriction": "error",
12+
"style": "error",
13+
"pedantic": "error",
14+
"suspicious": "error"
15+
},
16+
"plugins": [
17+
"import",
18+
"typescript",
19+
"unicorn",
20+
"jsdoc",
21+
"node",
22+
"promise",
23+
"oxc"
24+
],
25+
"rules": {
26+
// eslint
27+
"constructor-super": "error",
28+
"getter-return": "error",
29+
"no-undef": "error",
30+
"no-unreachable": "error",
31+
"no-var": "error",
32+
"no-eq-null": "error",
33+
"no-await-in-loop": "allow",
34+
"eqeqeq": ["error", "smart"],
35+
"init-declarations": "allow",
36+
"curly": "allow",
37+
"no-ternary": "allow",
38+
"max-params": ["error", 5],
39+
"no-await-expression-member": "error",
40+
"no-continue": "allow",
41+
"guard-for-in": "allow",
42+
"func-style": "allow",
43+
"sort-imports": "allow",
44+
"yoda": "allow",
45+
"sort-keys": "allow",
46+
"no-magic-numbers": "allow",
47+
"no-duplicate-imports": "error",
48+
"no-multi-assign": "error",
49+
"func-names": "error",
50+
"default-param-last": "error",
51+
"prefer-object-spread": "error",
52+
"no-undefined": "allow",
53+
"no-plusplus": "allow",
54+
// maybe warn
55+
"no-console": "warn",
56+
"no-extraneous-class": "allow",
57+
"no-empty-function": "error",
58+
"max-depth": ["error", 6],
59+
"max-lines-per-function": "allow",
60+
"no-lonely-if": "error",
61+
"max-lines": "allow",
62+
"require-await": "allow",
63+
"max-nested-callbacks": ["error", 5],
64+
"max-classes-per-file": "allow",
65+
"radix": "allow",
66+
"no-negated-condition": "error",
67+
"no-else-return": "error",
68+
"no-throw-literal": "error",
69+
70+
// import
71+
"import/exports-last": "allow",
72+
"import/max-dependencies": "allow",
73+
"import/no-cycle": "error",
74+
"import/no-anonymous-default-export": "allow",
75+
"import/no-namespace": "error",
76+
"import/named": "error",
77+
"import/export": "error",
78+
"import/no-default-export": "allow",
79+
"import/unambiguous": "error",
80+
81+
// promise
82+
"promise/no-return-wrap": "error",
83+
"promise/param-names": "error",
84+
"promise/prefer-await-to-callbacks": "error",
85+
"promise/prefer-await-to-then": "error",
86+
"promise/prefer-catch": "error",
87+
"promise/no-return-in-finally": "error",
88+
"promise/avoid-new": "error",
89+
90+
// unicorn
91+
"unicorn/error-message": "error",
92+
"unicorn/no-null": "allow",
93+
"unicorn/filename-case": "allow",
94+
"unicorn/prefer-structured-clone": "error",
95+
"unicorn/prefer-logical-operator-over-ternary": "error",
96+
"unicorn/prefer-number-properties": "error",
97+
"unicorn/prefer-array-some": "error",
98+
"unicorn/prefer-string-slice": "error",
99+
// "unicorn/no-null": "error",
100+
"unicorn/throw-new-error": "error",
101+
"unicorn/catch-error-name": "allow",
102+
"unicorn/prefer-spread": "allow",
103+
"unicorn/numeric-separators-style": "error",
104+
"unicorn/prefer-string-raw": "error",
105+
"unicorn/text-encoding-identifier-case": "error",
106+
"unicorn/no-array-for-each": "error",
107+
"unicorn/explicit-length-check": "error",
108+
"unicorn/no-lonely-if": "error",
109+
"unicorn/no-useless-undefined": "allow",
110+
"unicorn/prefer-date-now": "error",
111+
"unicorn/no-static-only-class": "allow",
112+
"unicorn/no-typeof-undefined": "error",
113+
"unicorn/prefer-negative-index": "error",
114+
"unicorn/no-anonymous-default-export": "allow",
115+
116+
// oxc
117+
"oxc/no-map-spread": "error",
118+
"oxc/no-rest-spread-properties": "allow",
119+
"oxc/no-optional-chaining": "allow",
120+
"oxc/no-async-await": "allow",
121+
122+
// typescript
123+
"typescript/explicit-function-return-type": "allow",
124+
"typescript/consistent-type-imports": "error",
125+
"typescript/consistent-type-definitions": "error",
126+
"typescript/consistent-indexed-object-style": "allow",
127+
"typescript/no-inferrable-types": "error",
128+
"typescript/array-type": "error",
129+
"typescript/no-non-null-assertion": "error",
130+
"typescript/no-explicit-any": "error",
131+
"typescript/no-import-type-side-effects": "error",
132+
"typescript/no-dynamic-delete": "error",
133+
"typescript/prefer-ts-expect-error": "error",
134+
"typescript/ban-ts-comment": "error",
135+
"typescript/prefer-enum-initializers": "error",
136+
137+
// jsdoc
138+
"jsdoc/require-returns": "allow",
139+
"jsdoc/require-param": "allow"
140+
},
141+
"ignorePatterns": ["index.d.ts", "test/fixtures/**", "__snapshots__"]
142+
}

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "es5",
4+
"tabWidth": 2,
5+
"arrowParens": "avoid"
6+
}

CHANGELOG.md

Lines changed: 41 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,116 +2,111 @@
22

33
## [5.0.0](https://github.com/eggjs/egg-mysql/compare/v4.1.0...v5.0.0) (2025-03-08)
44

5-
65
### ⚠ BREAKING CHANGES
76

8-
* drop Node.js < 18 support
9-
* use mysql2 instead of mysql
7+
- drop Node.js < 18 support
8+
- use mysql2 instead of mysql
109

1110
closes https://github.com/eggjs/egg-mysql/issues/31
1211

13-
1412
<!-- This is an auto-generated comment: release notes by coderabbit.ai
1513
-->
14+
1615
## Summary by CodeRabbit
1716

1817
- **Documentation**
1918
- Updated usage instructions and contributor displays with corrected
20-
typographical errors.
19+
typographical errors.
2120
- **Chores**
22-
- Removed outdated contributor templates and automation workflows.
21+
- Removed outdated contributor templates and automation workflows.
2322
- **Dependencies**
2423
- Migrated to a new database client package and raised the minimum
25-
Node.js version requirement.
24+
Node.js version requirement.
2625
- **Tests**
2726
- Refined error validations in database operations for improved error
2827
reporting.
2928
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
3029

3130
### Features
3231

33-
* use @eggjs/rds instead of ali-rds ([#32](https://github.com/eggjs/egg-mysql/issues/32)) ([3093528](https://github.com/eggjs/egg-mysql/commit/30935285268b1c674f9a70b4cb77501f89276467))
32+
- use @eggjs/rds instead of ali-rds ([#32](https://github.com/eggjs/egg-mysql/issues/32)) ([3093528](https://github.com/eggjs/egg-mysql/commit/30935285268b1c674f9a70b4cb77501f89276467))
3433

3534
## [4.1.0](https://github.com/eggjs/egg-mysql/compare/v4.0.0...v4.1.0) (2025-03-08)
3635

37-
3836
### Features
3937

40-
* update [email protected] ([#30](https://github.com/eggjs/egg-mysql/issues/30)) ([31ed369](https://github.com/eggjs/egg-mysql/commit/31ed369d954ce4bded89469907f81dcbde3060df))
38+
- update [email protected] ([#30](https://github.com/eggjs/egg-mysql/issues/30)) ([31ed369](https://github.com/eggjs/egg-mysql/commit/31ed369d954ce4bded89469907f81dcbde3060df))
4139

4240
## [4.0.0](https://github.com/eggjs/egg-mysql/compare/v3.4.0...v4.0.0) (2023-03-06)
4341

44-
4542
### ⚠ BREAKING CHANGES
4643

47-
* drop Node.js < 16 support
44+
- drop Node.js < 16 support
4845

4946
### Features
5047

51-
* refactor with TypeScript ([#27](https://github.com/eggjs/egg-mysql/issues/27)) ([4b7311d](https://github.com/eggjs/egg-mysql/commit/4b7311d2beb43a0338337c7128e016690ea04c9e))
48+
- refactor with TypeScript ([#27](https://github.com/eggjs/egg-mysql/issues/27)) ([4b7311d](https://github.com/eggjs/egg-mysql/commit/4b7311d2beb43a0338337c7128e016690ea04c9e))
5249

5350
## [3.4.0](https://github.com/eggjs/egg-mysql/compare/v3.3.0...v3.4.0) (2023-02-15)
5451

55-
5652
### Features
5753

58-
* **type:** add type definition for mysql.count method ([#26](https://github.com/eggjs/egg-mysql/issues/26)) ([7aef13e](https://github.com/eggjs/egg-mysql/commit/7aef13eb861b41c538d3b3d561c92a666a61110b))
54+
- **type:** add type definition for mysql.count method ([#26](https://github.com/eggjs/egg-mysql/issues/26)) ([7aef13e](https://github.com/eggjs/egg-mysql/commit/7aef13eb861b41c538d3b3d561c92a666a61110b))
5955

6056
## [3.3.0](https://github.com/eggjs/egg-mysql/compare/v3.2.0...v3.3.0) (2022-12-18)
6157

62-
6358
### Features
6459

65-
* upgrade ali-rds v4 ([#24](https://github.com/eggjs/egg-mysql/issues/24)) ([1b129e8](https://github.com/eggjs/egg-mysql/commit/1b129e8f94b0739a5515d5704be301df85f97b30))
60+
- upgrade ali-rds v4 ([#24](https://github.com/eggjs/egg-mysql/issues/24)) ([1b129e8](https://github.com/eggjs/egg-mysql/commit/1b129e8f94b0739a5515d5704be301df85f97b30))
6661

6762
---
6863

69-
3.2.0 / 2022-12-03
70-
==================
64+
# 3.2.0 / 2022-12-03
7165

7266
**features**
73-
* [[`4cf93ce`](http://github.com/eggjs/egg-mysql/commit/4cf93ce5fbeeb3fc734a8e7ba708b27994adad88)] - feat: add more type definition for mysql.get method (#20) (Xin(Khalil) Zhang <<[email protected]>>)
67+
68+
- [[`4cf93ce`](http://github.com/eggjs/egg-mysql/commit/4cf93ce5fbeeb3fc734a8e7ba708b27994adad88)] - feat: add more type definition for mysql.get method (#20) (Xin(Khalil) Zhang <<[email protected]>>)
7469

7570
**fixes**
76-
* [[`d3c8a31`](http://github.com/eggjs/egg-mysql/commit/d3c8a31e02beccc8823820340bda89fe307a34ea)] - fix: remove reckless assertion (#15) (WangJie <<[email protected]>>)
71+
72+
- [[`d3c8a31`](http://github.com/eggjs/egg-mysql/commit/d3c8a31e02beccc8823820340bda89fe307a34ea)] - fix: remove reckless assertion (#15) (WangJie <<[email protected]>>)
7773

7874
**others**
79-
* [[`ed419d6`](http://github.com/eggjs/egg-mysql/commit/ed419d6c51e25fa3ea2a4b91628375d4d4dcb77d)] - 🤖 TEST: Add tsd test (#22) (fengmk2 <<[email protected]>>)
80-
* [[`4137cfc`](http://github.com/eggjs/egg-mysql/commit/4137cfc46e0db04f6122b065516055a99765eb19)] - 📖 DOC: Use async/await isntead of yield (fengmk2 <<[email protected]>>)
81-
* [[`b103400`](http://github.com/eggjs/egg-mysql/commit/b103400c153176bd9c38e35d72aa3a791999ec27)] - 📖 DOC: Update contributors (fengmk2 <<[email protected]>>)
82-
* [[`a67989c`](http://github.com/eggjs/egg-mysql/commit/a67989c4e6c55604d8d61d1af7af9bc5df35df2e)] - 🤖 TEST: Run test on GitHub Action (#19) (fengmk2 <<[email protected]>>)
83-
* [[`3d04360`](http://github.com/eggjs/egg-mysql/commit/3d04360fd7745ef45d32e8e27c5691878d0cd3bf)] - Create codeql-analysis.yml (fengmk2 <<[email protected]>>)
8475

85-
3.1.1 / 2022-06-03
86-
==================
76+
- [[`ed419d6`](http://github.com/eggjs/egg-mysql/commit/ed419d6c51e25fa3ea2a4b91628375d4d4dcb77d)] - 🤖 TEST: Add tsd test (#22) (fengmk2 <<[email protected]>>)
77+
- [[`4137cfc`](http://github.com/eggjs/egg-mysql/commit/4137cfc46e0db04f6122b065516055a99765eb19)] - 📖 DOC: Use async/await isntead of yield (fengmk2 <<[email protected]>>)
78+
- [[`b103400`](http://github.com/eggjs/egg-mysql/commit/b103400c153176bd9c38e35d72aa3a791999ec27)] - 📖 DOC: Update contributors (fengmk2 <<[email protected]>>)
79+
- [[`a67989c`](http://github.com/eggjs/egg-mysql/commit/a67989c4e6c55604d8d61d1af7af9bc5df35df2e)] - 🤖 TEST: Run test on GitHub Action (#19) (fengmk2 <<[email protected]>>)
80+
- [[`3d04360`](http://github.com/eggjs/egg-mysql/commit/3d04360fd7745ef45d32e8e27c5691878d0cd3bf)] - Create codeql-analysis.yml (fengmk2 <<[email protected]>>)
81+
82+
# 3.1.1 / 2022-06-03
8783

8884
**fixes**
89-
* [[`bb7856b`](http://github.com/eggjs/egg-mysql/commit/bb7856bbf8e363f2ee0ce9410204fd227c2ccd08)] - fix: mysql.update missing condition define (#18) (shangwenhe <<[email protected]>>)
9085

91-
3.1.0 / 2022-02-11
92-
==================
86+
- [[`bb7856b`](http://github.com/eggjs/egg-mysql/commit/bb7856bbf8e363f2ee0ce9410204fd227c2ccd08)] - fix: mysql.update missing condition define (#18) (shangwenhe <<[email protected]>>)
87+
88+
# 3.1.0 / 2022-02-11
9389

9490
**features**
95-
* [[`aade70b`](http://github.com/eggjs/egg-mysql/commit/aade70bce78afb39e8e9b3201261bbb8bcf26847)] - feat: add complete typescript typings (#17) (AntiMoron <<[email protected]>>)
91+
92+
- [[`aade70b`](http://github.com/eggjs/egg-mysql/commit/aade70bce78afb39e8e9b3201261bbb8bcf26847)] - feat: add complete typescript typings (#17) (AntiMoron <<[email protected]>>)
9693

9794
**others**
98-
* [[`2e02e40`](http://github.com/eggjs/egg-mysql/commit/2e02e402d6d23740f68ae26c28633303d4d9e206)] - chore: update travis (#16) (TZ | 天猪 <<[email protected]>>)
99-
* [[`89910f6`](http://github.com/eggjs/egg-mysql/commit/89910f6ef17be38b59bc066d754793cc65a84624)] - test: add null query test case (#13) (Century Guo <<[email protected]>>)
100-
* [[`b0dd988`](http://github.com/eggjs/egg-mysql/commit/b0dd988d51b95d576c852d54d26014a845ac2f3d)] - deps: autod (#12) (TZ | 天猪 <<[email protected]>>)
101-
* [[`18b67fd`](http://github.com/eggjs/egg-mysql/commit/18b67fd3e43627ad420ed3df8e8a6e305f5202f6)] - deps: upgrade dependencies (#10) (Haoliang Gao <<[email protected]>>)
10295

103-
3.0.0 / 2017-04-03
104-
==================
96+
- [[`2e02e40`](http://github.com/eggjs/egg-mysql/commit/2e02e402d6d23740f68ae26c28633303d4d9e206)] - chore: update travis (#16) (TZ | 天猪 <<[email protected]>>)
97+
- [[`89910f6`](http://github.com/eggjs/egg-mysql/commit/89910f6ef17be38b59bc066d754793cc65a84624)] - test: add null query test case (#13) (Century Guo <<[email protected]>>)
98+
- [[`b0dd988`](http://github.com/eggjs/egg-mysql/commit/b0dd988d51b95d576c852d54d26014a845ac2f3d)] - deps: autod (#12) (TZ | 天猪 <<[email protected]>>)
99+
- [[`18b67fd`](http://github.com/eggjs/egg-mysql/commit/18b67fd3e43627ad420ed3df8e8a6e305f5202f6)] - deps: upgrade dependencies (#10) (Haoliang Gao <<[email protected]>>)
100+
101+
# 3.0.0 / 2017-04-03
105102

106-
* deps: ali-rds@3 (#9)
103+
- deps: ali-rds@3 (#9)
107104

108-
2.0.0 / 2017-02-09
109-
==================
105+
# 2.0.0 / 2017-02-09
110106

111-
* feat: remove app.instrument and fix test (#5)
107+
- feat: remove app.instrument and fix test (#5)
112108

113-
1.0.1 / 2016-12-30
114-
==================
109+
# 1.0.1 / 2016-12-30
115110

116-
* docs: add app.js and agent.js extend intro (#3)
117-
* docs: add English translation doc (#2)
111+
- docs: add app.js and agent.js extend intro (#3)
112+
- docs: add English translation doc (#2)

0 commit comments

Comments
 (0)