From 4816db4d0e111d9f46d8547a17b6cf430a89d225 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sun, 8 Dec 2024 22:57:29 +0800 Subject: [PATCH] feat: use detect-port v2 (#275) ## Summary by CodeRabbit ## Release Notes - **New Features** - Added new badges in the README for Node.js version and contributors, enhancing documentation visibility. - **Bug Fixes** - Updated Node.js version specifications in the CI workflow to include specific patch and additional major versions. - **Chores** - Upgraded dependencies in the project for improved compatibility and features. Removed outdated dependency. - Removed a GitHub Actions workflow for CodeQL analysis to streamline processes. - Enabled debug output in several test cases for better troubleshooting. --- .github/workflows/codeql-analysis.yml | 68 --------------------------- .github/workflows/nodejs.yml | 2 +- README.md | 16 ++----- package.json | 5 +- test/cmd/cov.test.ts | 2 +- test/cmd/dev.test.ts | 2 +- test/cmd/test.test.ts | 9 ++-- test/ts.test.ts | 5 +- 8 files changed, 19 insertions(+), 90 deletions(-) delete mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index b4d31e96..00000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,68 +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 ] - -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. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # 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 - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index ad35cba1..6c22ae29 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -13,4 +13,4 @@ jobs: uses: node-modules/github-actions/.github/workflows/node-test.yml@master with: os: 'ubuntu-latest, macos-latest, windows-latest' - version: '16, 18, 20' + version: '16.19.0, 16, 18, 20, 22' diff --git a/README.md b/README.md index 3da61dae..d0d41a1f 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ [![Test coverage][codecov-image]][codecov-url] [![Known Vulnerabilities][snyk-image]][snyk-url] [![npm download][download-image]][download-url] +[![Node.js Version][node-version-image]][node-version-url] [npm-image]: https://img.shields.io/npm/v/egg-bin.svg?style=flat-square [npm-url]: https://npmjs.org/package/egg-bin @@ -16,6 +17,8 @@ [snyk-url]: https://snyk.io/test/npm/egg-bin [download-image]: https://img.shields.io/npm/dm/egg-bin.svg?style=flat-square [download-url]: https://npmjs.org/package/egg-bin +[node-version-image]: https://img.shields.io/node/v/egg-bin.svg?style=flat-square +[node-version-url]: https://nodejs.org/en/download/ egg developer tool, extends [@artus-cli/artus-cli]. @@ -212,20 +215,11 @@ See [MIT](LICENSE) - - ## Contributors -|[
fengmk2](https://github.com/fengmk2)
|[
atian25](https://github.com/atian25)
|[
popomore](https://github.com/popomore)
|[
whxaxes](https://github.com/whxaxes)
|[
semantic-release-bot](https://github.com/semantic-release-bot)
|[
dead-horse](https://github.com/dead-horse)
| -| :---: | :---: | :---: | :---: | :---: | :---: | -|[
killagu](https://github.com/killagu)
|[
hyj1991](https://github.com/hyj1991)
|[
mansonchor](https://github.com/mansonchor)
|[
ngot](https://github.com/ngot)
|[
waitingsong](https://github.com/waitingsong)
|[
onlylovermb](https://github.com/onlylovermb)
| -|[
snyk-bot](https://github.com/snyk-bot)
|[
BiosSun](https://github.com/BiosSun)
|[
luckydrq](https://github.com/luckydrq)
|[
gxkl](https://github.com/gxkl)
|[
stormslowly](https://github.com/stormslowly)
|[
Solais](https://github.com/Solais)
| -|[
snapre](https://github.com/snapre)
|[
ZYSzys](https://github.com/ZYSzys)
|[
angleshe](https://github.com/angleshe)
|[
ahungrynoob](https://github.com/ahungrynoob)
|[
yinseny](https://github.com/yinseny)
|[
liuhanqu](https://github.com/liuhanqu)
| -[
okoala](https://github.com/okoala)
- -This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Sat Jun 03 2023 16:58:54 GMT+0800`. +[![Contributors](https://contrib.rocks/image?repo=eggjs/egg-bin)](https://github.com/eggjs/egg-bin/graphs/contributors) - +Made with [contributors-img](https://contrib.rocks). [mocha]: https://mochajs.org [glob]: https://github.com/isaacs/node-glob diff --git a/package.json b/package.json index 6d5e69f6..1b57bb09 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "@artus-cli/plugin-version": "^1.0.1", "@eggjs/utils": "^3.0.1", "c8": "^10.0.0", - "detect-port": "^1.3.0", + "detect-port": "^2.0.0", "egg-ts-helper": "^2.1.0", "globby": "^11.1.0", "jest-changed-files": "^29.4.2", @@ -42,7 +42,7 @@ "@swc-node/register": "^1.6.1", "@swc/core": "^1.3.35", "@types/mocha": "^10.0.1", - "@types/node": "^20.6.1", + "@types/node": "^22.10.1", "assert-file": "^1.0.0", "coffee": "^5.4.0", "cpy": "^8.1.2", @@ -52,7 +52,6 @@ "esbuild-register": "^3.4.2", "eslint": "^8.16.0", "eslint-config-egg": "^13.1.0", - "git-contributor": "2", "npminstall": "^7.5.0", "typescript": "^5.2.2" }, diff --git a/test/cmd/cov.test.ts b/test/cmd/cov.test.ts index 5fc294af..064dded0 100644 --- a/test/cmd/cov.test.ts +++ b/test/cmd/cov.test.ts @@ -189,7 +189,7 @@ describe('test/cmd/cov.test.ts', () => { }); it('should support egg.revert', () => { - if (version < 18) return; + if (version < 18 || version > 20) return; mm(process.env, 'NODE_ENV', 'development'); return coffee.fork(eggBin, [ 'cov' ], { cwd: path.join(__dirname, '../fixtures/egg-revert'), diff --git a/test/cmd/dev.test.ts b/test/cmd/dev.test.ts index c7b76d7b..be11889c 100644 --- a/test/cmd/dev.test.ts +++ b/test/cmd/dev.test.ts @@ -191,7 +191,7 @@ describe('test/cmd/dev.test.ts', () => { }); it('should support egg.revert', () => { - if (version < 18) return; + if (version < 18 || version > 20) return; mm(process.env, 'NODE_ENV', 'development'); return coffee.fork(eggBin, [ 'dev' ], { cwd: path.join(__dirname, '../fixtures/egg-revert'), diff --git a/test/cmd/test.test.ts b/test/cmd/test.test.ts index d3608cf6..d946e038 100644 --- a/test/cmd/test.test.ts +++ b/test/cmd/test.test.ts @@ -11,7 +11,7 @@ describe('test/cmd/test.test.ts', () => { describe('egg-bin test', () => { it('should success js', () => { return coffee.fork(eggBin, [ 'test' ], { cwd }) - // .debug() + .debug() .expect('stdout', /should success/) .expect('stdout', /a\.test\.js/) .expect('stdout', /b\/b\.test\.js/) @@ -183,9 +183,10 @@ describe('test/cmd/test.test.ts', () => { .end(); }); - it('should success js', () => { + it('should success js on unhandled-rejection', () => { + if (version >= 20 && process.platform === 'win32') return; return coffee.fork(eggBin, [ 'test' ], { cwd: path.join(fixtures, 'test-unhandled-rejection') }) - // .debug() + .debug() .expect('stdout', / Uncaught Error: mock error/) .expect('code', 1) .end(); @@ -308,7 +309,7 @@ describe('test/cmd/test.test.ts', () => { }); it('should support egg.revert', () => { - if (version < 18) return; + if (version < 18 || version > 20) return; return coffee.fork(eggBin, [ 'test' ], { cwd: path.join(__dirname, '../fixtures/egg-revert'), }) diff --git a/test/ts.test.ts b/test/ts.test.ts index c1a312fc..a9db2800 100644 --- a/test/ts.test.ts +++ b/test/ts.test.ts @@ -5,6 +5,8 @@ import _cpy from 'cpy'; import runscript from 'runscript'; import coffee from './coffee'; +const version = Number(process.version.substring(1, 3)); + async function cpy(src: string, target: string) { if (fs.cp) { await fs.cp(src, target, { force: true, recursive: true }); @@ -74,13 +76,14 @@ describe('test/ts.test.ts', () => { }); it('should cov app in cluster mod', () => { + if (version > 20) return; // skip on darwin // https://github.com/eggjs/egg-bin/runs/6735190362?check_suite_focus=true // [agent_worker] receive disconnect event on child_process fork mode, exiting with code:110 if (process.platform === 'darwin') return; cwd = path.join(fixtures, 'example-ts-cluster'); return coffee.fork(eggBin, [ 'cov' ], { cwd }) - // .debug() + .debug() .expect('stdout', /Statements/) .expect('code', 0) .end();