Skip to content

Commit 3ae61c2

Browse files
feat: upgrade to egg v4 (#126)
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 * **Chores** * Enhanced CI/CD pipeline to test across multiple Node.js versions (20, 22, 24) and operating systems (Ubuntu, macOS). * Increased Node.js requirement to >= 20. * Updated Egg.js framework and related tooling packages to beta versions. * Migrated projects to TypeScript and ES modules for improved type safety. * Updated development dependencies and build tooling infrastructure. * Refreshed documentation badges and build configuration. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 5ea83ef commit 3ae61c2

35 files changed

+229
-200
lines changed

.github/PULL_REQUEST_TEMPLATE.md

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

.github/workflows/ci.yml

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,35 @@ name: CI
33
on:
44
push:
55
branches: [ master ]
6-
76
pull_request:
87
branches: [ master ]
98

10-
workflow_dispatch: {}
11-
129
jobs:
13-
Job:
14-
name: Node.js
15-
uses: artusjs/github-actions/.github/workflows/node-test.yml@master
16-
with:
17-
os: 'ubuntu-latest'
18-
version: '14, 16, 18'
10+
test:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: ['ubuntu-latest', 'macos-latest']
15+
node: ['20', '22', '24']
16+
17+
name: Test (${{ matrix.os }}, node@${{ matrix.node }})
18+
runs-on: ${{ matrix.os }}
19+
20+
concurrency:
21+
group: test-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}-(${{ matrix.os }}, ${{ matrix.node }})
22+
cancel-in-progress: true
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
27+
28+
- name: Set up Node.js
29+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
30+
with:
31+
node-version: ${{ matrix.node }}
32+
33+
- name: Install dependencies
34+
run: npm i -g npminstall && npminstall
35+
36+
- name: Test
37+
run: npm run ci

README.md

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
# Examples for [egg](https://github.com/eggjs/egg)
22

3-
---
4-
5-
[![build status][travis-image]][travis-url]
3+
[![CI](https://github.com/eggjs/examples/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/eggjs/examples/actions/workflows/ci.yml)
64
[![node version][node-image]][node-url]
75
[![egg version][egg-image]][egg-url]
86

9-
[travis-image]: https://img.shields.io/travis/eggjs/examples.svg?style=flat-square
10-
[travis-url]: https://travis-ci.org/eggjs/examples
11-
[node-image]: https://img.shields.io/badge/node.js-%3E=_8-green.svg?style=flat-square
7+
[node-image]: https://img.shields.io/badge/node.js-%3E=_20-green.svg?style=flat-square
128
[node-url]: http://nodejs.org/download/
13-
[egg-image]: https://img.shields.io/badge/egg-%3E=_1-green.svg?style=flat-square
9+
[egg-image]: https://img.shields.io/badge/egg-%3E=_4-green.svg?style=flat-square
1410
[egg-url]: https://github.com/eggjs/egg
1511

1612
## Usage
@@ -23,7 +19,7 @@ $ npm install
2319
$ npm run dev
2420
```
2521

26-
**Recommend to use Node >= 8**
22+
**Recommend to use Node >= 20**
2723

2824
## List of examples
2925

@@ -64,12 +60,6 @@ You can use `--verbose` to show more infomation
6460
$ npm test -- --verbose
6561
```
6662

67-
### Generate dependencies
68-
69-
```bash
70-
$ npm run autod
71-
```
72-
7363
### Show list of examples
7464

7565
```bash

bin/test.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
set -eux -o pipefail
4+
5+
test() {
6+
echo "Test $1"
7+
cd "$1"
8+
pwd
9+
rm -rf node_modules package-lock.json
10+
npmupdate -c
11+
npm run ci
12+
cd ..
13+
}
14+
15+
test body-parser-example
16+
test helloworld
17+
test hello-tegg
File renamed without changes.

bodyParser/app/controller/home.js renamed to body-parser-example/app/controller/home.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
'use strict';
2-
3-
const Controller = require('egg').Controller;
1+
const { Controller } = require('egg');
42
const { xml2js } = require('xml-js');
53

64
class HomeController extends Controller {
File renamed without changes.

bodyParser/config/config.default.js renamed to body-parser-example/config/config.default.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
exports.keys = '123456';
42

53
exports.bodyParser = {
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
2-
"name": "bodyParser",
2+
"name": "body-parser-example",
33
"version": "1.0.0",
44
"dependencies": {
5-
"egg": "^2",
5+
"egg": "beta",
66
"xml-js": "^1.6.9"
77
},
88
"devDependencies": {
9-
"egg-bin": "^4.3.5",
10-
"egg-mock": "^3.13.1"
9+
"@eggjs/bin": "beta",
10+
"@eggjs/mock": "beta"
1111
},
1212
"scripts": {
1313
"dev": "egg-bin dev",
1414
"test": "egg-bin test",
15-
"cov": "egg-bin cov"
15+
"ci": "egg-bin cov"
1616
},
1717
"private": true
1818
}

bodyParser/test/home.test.js renamed to body-parser-example/test/home.test.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
'use strict';
2-
3-
const { app } = require('egg-mock/bootstrap');
4-
5-
describe('test/app/controller/home.test.js', () => {
1+
const { app } = require('@eggjs/mock/bootstrap');
62

3+
describe('test/home.test.js', () => {
74
beforeEach(() => app.mockCsrf());
85

96
it('should parse form', () => {

0 commit comments

Comments
 (0)