Skip to content

Commit

Permalink
feat: support cjs and esm both by tshy (#33)
Browse files Browse the repository at this point in the history
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 -->
  • Loading branch information
fengmk2 authored Feb 3, 2025
1 parent 3863a39 commit fa42511
Show file tree
Hide file tree
Showing 44 changed files with 725 additions and 598 deletions.
5 changes: 3 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
coverage/
test/fixtures
coverage
__snapshots__
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "eslint-config-egg"
"extends": [
"eslint-config-egg/typescript",
"eslint-config-egg/lib/rules/enforce-node-prefix"
]
}
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
with:
os: 'ubuntu-latest, windows-latest, macos-latest'
version: '14, 16, 18, 20, 22'
version: '18, 20, 22'
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ run/
.DS_Store
*.swp
test/fixtures/**/run
.tshy*
.eslintcache
dist
package-lock.json
.package-lock.json
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
# egg-logrotator
# @eggjs/logrotator

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

[npm-image]: https://img.shields.io/npm/v/egg-logrotator.svg?style=flat-square
[npm-url]: https://npmjs.org/package/egg-logrotator
[download-image]: https://img.shields.io/npm/dm/egg-logrotator.svg?style=flat-square
[download-url]: https://npmjs.org/package/egg-logrotator
[npm-image]: https://img.shields.io/npm/v/@eggjs/logrotator.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@eggjs/logrotator
[download-image]: https://img.shields.io/npm/dm/@eggjs/logrotator.svg?style=flat-square
[download-url]: https://npmjs.org/package/@eggjs/logrotator

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

## Install

```bash
npm i egg-logrotator
npm i @eggjs/logrotator
```

## Usage
Expand All @@ -25,7 +28,7 @@ npm i egg-logrotator
```js
exports.logrotator = {
enable: true,
package: 'egg-logrotator',
package: '@eggjs/logrotator',
};
```

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

## License

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

## Contributors

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

Made with [contributors-img](https://contrib.rocks).
21 changes: 12 additions & 9 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# egg-logrotator
# @eggjs/logrotator

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

[npm-image]: https://img.shields.io/npm/v/egg-logrotator.svg?style=flat-square
[npm-url]: https://npmjs.org/package/egg-logrotator
[download-image]: https://img.shields.io/npm/dm/egg-logrotator.svg?style=flat-square
[download-url]: https://npmjs.org/package/egg-logrotator
[npm-image]: https://img.shields.io/npm/v/@eggjs/logrotator.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@eggjs/logrotator
[download-image]: https://img.shields.io/npm/dm/@eggjs/logrotator.svg?style=flat-square
[download-url]: https://npmjs.org/package/@eggjs/logrotator

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

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

## License

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

## Contributors

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

Made with [contributors-img](https://contrib.rocks).
11 changes: 11 additions & 0 deletions __snapshots__/clean_log.test.ts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
exports['test/clean_log.test.ts should keep config stable 1'] = {
"disableRotateByDay": false,
"filesRotateByHour": null,
"hourDelimiter": "-",
"filesRotateBySize": null,
"maxFileSize": 52428800,
"maxFiles": 10,
"rotateDuration": 60000,
"maxDays": 31,
"gzip": false
}
9 changes: 0 additions & 9 deletions agent.js

This file was deleted.

9 changes: 0 additions & 9 deletions app.js

This file was deleted.

8 changes: 0 additions & 8 deletions app/extend/agent.js

This file was deleted.

7 changes: 0 additions & 7 deletions app/extend/application.js

This file was deleted.

87 changes: 0 additions & 87 deletions app/lib/rotator.js

This file was deleted.

70 changes: 0 additions & 70 deletions app/schedule/clean_log.js

This file was deleted.

29 changes: 0 additions & 29 deletions config/config.default.js

This file was deleted.

Loading

0 comments on commit fa42511

Please sign in to comment.