From ab5e56ce103bf590472d05962b8a1b0fba88bd47 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Tue, 4 Feb 2025 11:33:55 +0800 Subject: [PATCH] feat: support cjs and esm both by tshy BREAKING CHANGE: drop Node.js < 18.19.0 support part of https://github.com/eggjs/egg/issues/3644 https://github.com/eggjs/egg/issues/5257 --- .eslintrc | 5 +- .github/PULL_REQUEST_TEMPLATE.md | 24 ---- .github/workflows/codeql.yml | 41 ------- .github/workflows/nodejs.yml | 51 ++------- .github/workflows/release.yml | 12 ++ History.md => CHANGELOG.md | 0 README.md | 14 +++ boilerplate/.eslintignore | 2 + boilerplate/.eslintrc | 5 +- boilerplate/.github/PULL_REQUEST_TEMPLATE.md | 24 ---- boilerplate/.github/workflows/nodejs.yml | 17 +++ boilerplate/.github/workflows/release.yml | 12 ++ boilerplate/README.md | 36 +++--- boilerplate/_package.json | 104 ++++++++++++------ boilerplate/config/config.default.js | 10 -- boilerplate/src/config/config.default.ts | 21 ++++ boilerplate/src/index.ts | 1 + boilerplate/src/typings/index.d.ts | 4 + .../apps/example/app/controller/home.js | 3 +- .../test/fixtures/apps/example/app/router.js | 2 - .../apps/example/config/config.default.js | 2 - boilerplate/test/index.test.js | 23 ---- boilerplate/test/index.test.ts | 21 ++++ boilerplate/tsconfig.json | 10 ++ index.js | 2 - package.json | 16 ++- 26 files changed, 231 insertions(+), 231 deletions(-) delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/release.yml rename History.md => CHANGELOG.md (100%) delete mode 100644 boilerplate/.github/PULL_REQUEST_TEMPLATE.md create mode 100644 boilerplate/.github/workflows/nodejs.yml create mode 100644 boilerplate/.github/workflows/release.yml delete mode 100644 boilerplate/config/config.default.js create mode 100644 boilerplate/src/config/config.default.ts create mode 100644 boilerplate/src/index.ts create mode 100644 boilerplate/src/typings/index.d.ts delete mode 100644 boilerplate/test/index.test.js create mode 100644 boilerplate/test/index.test.ts create mode 100644 boilerplate/tsconfig.json diff --git a/.eslintrc b/.eslintrc index c799fe5..89803ed 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,3 +1,6 @@ { - "extends": "eslint-config-egg" + "extends": [ + "eslint-config-egg", + "eslint-config-egg/lib/rules/enforce-node-prefix" + ] } 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.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 6094b17..0000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: "CodeQL" - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - schedule: - - cron: "26 2 * * 0" - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ javascript ] - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - queries: +security-and-quality - - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{ matrix.language }}" diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 9a4cb4d..63d1994 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -1,46 +1,17 @@ -# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - -name: Node.js CI +name: CI on: push: - branches: - - main - - master + branches: [ master ] pull_request: - branches: - - main - - master - schedule: - - cron: '0 2 * * *' + branches: [ master ] jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - node-version: [16] - os: [ubuntu-latest, windows-latest, macos-latest] - - steps: - - name: Checkout Git Source - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Install Dependencies - run: npm i - - - name: Continuous Integration - run: npm run ci - - - name: Code Coverage - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} + Job: + name: Node.js + uses: node-modules/github-actions/.github/workflows/node-test.yml@master + with: + os: 'ubuntu-latest, macos-latest, windows-latest' + version: '18, 20, 22' + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..970aedc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,12 @@ +name: Release +on: + push: + branches: [ master ] + +jobs: + release: + name: Node.js + uses: eggjs/github-actions/.github/workflows/node-release.yml@master + secrets: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GIT_TOKEN: ${{ secrets.GIT_TOKEN }} diff --git a/History.md b/CHANGELOG.md similarity index 100% rename from History.md rename to CHANGELOG.md diff --git a/README.md b/README.md index 57fd5c8..bf03c38 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,17 @@ # egg-boilerplate-plugin Boilerplate for egg plugin. See [egg-init](https://github.com/eggjs/egg-init). + +## Questions & Suggestions + +Please open an issue [here](https://github.com/eggjs/egg/issues). + +## License + +[MIT](LICENSE) + +## Contributors + +[![Contributors](https://contrib.rocks/image?repo=eggjs/egg-boilerplate-plugin)](https://github.com/eggjs/egg-boilerplate-plugin/graphs/contributors) + +Made with [contributors-img](https://contrib.rocks). diff --git a/boilerplate/.eslintignore b/boilerplate/.eslintignore index 4ebc8ae..618ef2b 100644 --- a/boilerplate/.eslintignore +++ b/boilerplate/.eslintignore @@ -1 +1,3 @@ +test/fixtures coverage +__snapshots__ diff --git a/boilerplate/.eslintrc b/boilerplate/.eslintrc index f304bdd..98f7371 100644 --- a/boilerplate/.eslintrc +++ b/boilerplate/.eslintrc @@ -1,4 +1,7 @@ { - "extends": "eslint-config-egg", + "extends": [ + "eslint-config-egg/typescript", + "eslint-config-egg/lib/rules/enforce-node-prefix" + ], "root": true } diff --git a/boilerplate/.github/PULL_REQUEST_TEMPLATE.md b/boilerplate/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 48f9944..0000000 --- a/boilerplate/.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/boilerplate/.github/workflows/nodejs.yml b/boilerplate/.github/workflows/nodejs.yml new file mode 100644 index 0000000..63d1994 --- /dev/null +++ b/boilerplate/.github/workflows/nodejs.yml @@ -0,0 +1,17 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + Job: + name: Node.js + uses: node-modules/github-actions/.github/workflows/node-test.yml@master + with: + os: 'ubuntu-latest, macos-latest, windows-latest' + version: '18, 20, 22' + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/boilerplate/.github/workflows/release.yml b/boilerplate/.github/workflows/release.yml new file mode 100644 index 0000000..970aedc --- /dev/null +++ b/boilerplate/.github/workflows/release.yml @@ -0,0 +1,12 @@ +name: Release +on: + push: + branches: [ master ] + +jobs: + release: + name: Node.js + uses: eggjs/github-actions/.github/workflows/node-release.yml@master + secrets: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GIT_TOKEN: ${{ secrets.GIT_TOKEN }} diff --git a/boilerplate/README.md b/boilerplate/README.md index a4c699f..491713d 100644 --- a/boilerplate/README.md +++ b/boilerplate/README.md @@ -1,24 +1,18 @@ -# egg-{{name}} +# @eggjs/{{name}} [![NPM version][npm-image]][npm-url] -[![build status][travis-image]][travis-url] [![Test coverage][codecov-image]][codecov-url] -[![David deps][david-image]][david-url] [![Known Vulnerabilities][snyk-image]][snyk-url] [![npm download][download-image]][download-url] -[npm-image]: https://img.shields.io/npm/v/egg-{{name}}.svg?style=flat-square -[npm-url]: https://npmjs.org/package/egg-{{name}} -[travis-image]: https://img.shields.io/travis/eggjs/egg-{{name}}.svg?style=flat-square -[travis-url]: https://travis-ci.org/eggjs/egg-{{name}} -[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-{{name}}.svg?style=flat-square -[codecov-url]: https://codecov.io/github/eggjs/egg-{{name}}?branch=master -[david-image]: https://img.shields.io/david/eggjs/egg-{{name}}.svg?style=flat-square -[david-url]: https://david-dm.org/eggjs/egg-{{name}} -[snyk-image]: https://snyk.io/test/npm/egg-{{name}}/badge.svg?style=flat-square -[snyk-url]: https://snyk.io/test/npm/egg-{{name}} -[download-image]: https://img.shields.io/npm/dm/egg-{{name}}.svg?style=flat-square -[download-url]: https://npmjs.org/package/egg-{{name}} +[npm-image]: https://img.shields.io/npm/v/@eggjs/{{name}}.svg?style=flat-square +[npm-url]: https://npmjs.org/package/@eggjs/{{name}} +[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/{{name}}.svg?style=flat-square +[codecov-url]: https://codecov.io/github/eggjs/{{name}}?branch=master +[snyk-image]: https://snyk.io/test/npm/@eggjs/{{name}}/badge.svg?style=flat-square +[snyk-url]: https://snyk.io/test/npm/@eggjs/{{name}} +[download-image]: https://img.shields.io/npm/dm/@eggjs/{{name}}.svg?style=flat-square +[download-url]: https://npmjs.org/package/@eggjs/{{name}}