Skip to content

Commit fa42511

Browse files
authored
feat: support cjs and esm both by tshy (#33)
BREAKING CHANGE: drop Node.js < 18.19.0 support part of eggjs/egg#3644 eggjs/egg#5257 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Package renamed to **@eggjs/logrotator** with updated installation instructions and documentation. - Enhanced log rotation configuration for improved file retention and compression. - **Refactor** - Migrated the codebase to ES Modules with full TypeScript support. - Streamlined asynchronous handling in both core functionality and tests. - **Chores** - Updated CI workflows to support modern Node.js versions (18, 20, 22). - Refined linting and version control ignore configurations. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 3863a39 commit fa42511

File tree

44 files changed

+725
-598
lines changed

Some content is hidden

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

44 files changed

+725
-598
lines changed

.eslintignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
node_modules/
2-
coverage/
1+
test/fixtures
2+
coverage
3+
__snapshots__

.eslintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"extends": "eslint-config-egg"
2+
"extends": [
3+
"eslint-config-egg/typescript",
4+
"eslint-config-egg/lib/rules/enforce-node-prefix"
5+
]
36
}

.github/workflows/nodejs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ jobs:
1212
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
1313
with:
1414
os: 'ubuntu-latest, windows-latest, macos-latest'
15-
version: '14, 16, 18, 20, 22'
15+
version: '18, 20, 22'
1616
secrets:
1717
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ run/
77
.DS_Store
88
*.swp
99
test/fixtures/**/run
10+
.tshy*
11+
.eslintcache
12+
dist
13+
package-lock.json
14+
.package-lock.json

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
# egg-logrotator
1+
# @eggjs/logrotator
22

33
[![NPM version][npm-image]][npm-url]
4-
[![CI](https://github.com/eggjs/egg-logrotator/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/egg-logrotator/actions/workflows/nodejs.yml)
5-
[![Test coverage](https://img.shields.io/codecov/c/github/eggjs/egg-logrotator.svg?style=flat-square)](https://codecov.io/gh/eggjs/egg-logrotator)
4+
[![CI](https://github.com/eggjs/logrotator/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/logrotator/actions/workflows/nodejs.yml)
5+
[![Test coverage](https://img.shields.io/codecov/c/github/eggjs/logrotator.svg?style=flat-square)](https://codecov.io/gh/eggjs/logrotator)
66
[![npm download][download-image]][download-url]
7+
[![Node.js Version](https://img.shields.io/node/v/@eggjs/logrotator.svg?style=flat)](https://nodejs.org/en/download/)
8+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)
9+
![CodeRabbit Pull Request Reviews](https://img.shields.io/coderabbit/prs/github/eggjs/security)
710

8-
[npm-image]: https://img.shields.io/npm/v/egg-logrotator.svg?style=flat-square
9-
[npm-url]: https://npmjs.org/package/egg-logrotator
10-
[download-image]: https://img.shields.io/npm/dm/egg-logrotator.svg?style=flat-square
11-
[download-url]: https://npmjs.org/package/egg-logrotator
11+
[npm-image]: https://img.shields.io/npm/v/@eggjs/logrotator.svg?style=flat-square
12+
[npm-url]: https://npmjs.org/package/@eggjs/logrotator
13+
[download-image]: https://img.shields.io/npm/dm/@eggjs/logrotator.svg?style=flat-square
14+
[download-url]: https://npmjs.org/package/@eggjs/logrotator
1215

1316
LogRotator for egg. Rotate all file of `app.loggers` by default
1417

1518
## Install
1619

1720
```bash
18-
npm i egg-logrotator
21+
npm i @eggjs/logrotator
1922
```
2023

2124
## Usage
@@ -25,7 +28,7 @@ npm i egg-logrotator
2528
```js
2629
exports.logrotator = {
2730
enable: true,
28-
package: 'egg-logrotator',
31+
package: '@eggjs/logrotator',
2932
};
3033
```
3134

@@ -111,10 +114,10 @@ Please open an issue [here](https://github.com/eggjs/egg/issues).
111114

112115
## License
113116

114-
[MIT](https://github.com/eggjs/egg-logrotator/blob/master/LICENSE)
117+
[MIT](LICENSE)
115118

116119
## Contributors
117120

118-
[![Contributors](https://contrib.rocks/image?repo=eggjs/egg-logrotator)](https://github.com/eggjs/egg-logrotator/graphs/contributors)
121+
[![Contributors](https://contrib.rocks/image?repo=eggjs/logrotator)](https://github.com/eggjs/logrotator/graphs/contributors)
119122

120123
Made with [contributors-img](https://contrib.rocks).

README.zh-CN.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
# egg-logrotator
1+
# @eggjs/logrotator
22

33
[![NPM version][npm-image]][npm-url]
4-
[![CI](https://github.com/eggjs/egg-logrotator/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/egg-logrotator/actions/workflows/nodejs.yml)
5-
[![Test coverage](https://img.shields.io/codecov/c/github/eggjs/egg-logrotator.svg?style=flat-square)](https://codecov.io/gh/eggjs/egg-logrotator)
4+
[![CI](https://github.com/eggjs/logrotator/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/logrotator/actions/workflows/nodejs.yml)
5+
[![Test coverage](https://img.shields.io/codecov/c/github/eggjs/logrotator.svg?style=flat-square)](https://codecov.io/gh/eggjs/logrotator)
66
[![npm download][download-image]][download-url]
7+
[![Node.js Version](https://img.shields.io/node/v/@eggjs/logrotator.svg?style=flat)](https://nodejs.org/en/download/)
8+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)
9+
![CodeRabbit Pull Request Reviews](https://img.shields.io/coderabbit/prs/github/eggjs/security)
710

8-
[npm-image]: https://img.shields.io/npm/v/egg-logrotator.svg?style=flat-square
9-
[npm-url]: https://npmjs.org/package/egg-logrotator
10-
[download-image]: https://img.shields.io/npm/dm/egg-logrotator.svg?style=flat-square
11-
[download-url]: https://npmjs.org/package/egg-logrotator
11+
[npm-image]: https://img.shields.io/npm/v/@eggjs/logrotator.svg?style=flat-square
12+
[npm-url]: https://npmjs.org/package/@eggjs/logrotator
13+
[download-image]: https://img.shields.io/npm/dm/@eggjs/logrotator.svg?style=flat-square
14+
[download-url]: https://npmjs.org/package/@eggjs/logrotator
1215

1316
egg 的日志切割插件,默认会按照时间切割所有的 app.loggers。
1417

@@ -103,10 +106,10 @@ Please open an issue [here](https://github.com/eggjs/egg/issues).
103106

104107
## License
105108

106-
[MIT](https://github.com/eggjs/egg-logrotator/blob/master/LICENSE)
109+
[MIT](LICENSE)
107110

108111
## Contributors
109112

110-
[![Contributors](https://contrib.rocks/image?repo=eggjs/egg-logrotator)](https://github.com/eggjs/egg-logrotator/graphs/contributors)
113+
[![Contributors](https://contrib.rocks/image?repo=eggjs/logrotator)](https://github.com/eggjs/logrotator/graphs/contributors)
111114

112115
Made with [contributors-img](https://contrib.rocks).

__snapshots__/clean_log.test.ts.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
exports['test/clean_log.test.ts should keep config stable 1'] = {
2+
"disableRotateByDay": false,
3+
"filesRotateByHour": null,
4+
"hourDelimiter": "-",
5+
"filesRotateBySize": null,
6+
"maxFileSize": 52428800,
7+
"maxFiles": 10,
8+
"rotateDuration": 60000,
9+
"maxDays": 31,
10+
"gzip": false
11+
}

agent.js

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

app.js

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

app/extend/agent.js

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

0 commit comments

Comments
 (0)