Skip to content

Commit aab31f5

Browse files
authored
Merge pull request #1 from hubot-friends/node-test-runner
feat: Upgrade to latest path-to-regexp
2 parents 2a00da2 + e7b6dcc commit aab31f5

File tree

201 files changed

+12967
-12901
lines changed

Some content is hidden

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

201 files changed

+12967
-12901
lines changed

.eslintrc.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ rules:
66
indent: [error, 2, { MemberExpression: "off", SwitchCase: 1 }]
77
no-trailing-spaces: error
88
no-unused-vars: [error, { vars: all, args: none, ignoreRestSiblings: true }]
9+
parserOptions:
10+
ecmaVersion: latest
11+
sourceType: module
12+
env:
13+
es6: true

.github/workflows/ci.yml

Lines changed: 54 additions & 196 deletions
Original file line numberDiff line numberDiff line change
@@ -5,206 +5,64 @@ on:
55
- push
66

77
jobs:
8-
test:
8+
build:
9+
name: Build and Verify
910
runs-on: ubuntu-latest
1011
strategy:
1112
fail-fast: false
1213
matrix:
13-
name:
14-
- Node.js 0.10
15-
- Node.js 0.12
16-
- io.js 1.x
17-
- io.js 2.x
18-
- io.js 3.x
19-
- Node.js 4.x
20-
- Node.js 5.x
21-
- Node.js 6.x
22-
- Node.js 7.x
23-
- Node.js 8.x
24-
- Node.js 9.x
25-
- Node.js 10.x
26-
- Node.js 11.x
27-
- Node.js 12.x
28-
- Node.js 13.x
29-
- Node.js 14.x
30-
- Node.js 15.x
31-
- Node.js 16.x
32-
- Node.js 17.x
33-
- Node.js 18.x
34-
- Node.js 19.x
35-
36-
include:
37-
- name: Node.js 0.10
38-
node-version: "0.10"
39-
40-
41-
- name: Node.js 0.12
42-
node-version: "0.12"
43-
44-
45-
- name: io.js 1.x
46-
node-version: "1.8"
47-
48-
49-
- name: io.js 2.x
50-
node-version: "2.5"
51-
52-
53-
- name: io.js 3.x
54-
node-version: "3.3"
55-
56-
57-
- name: Node.js 4.x
58-
node-version: "4.9"
59-
60-
61-
- name: Node.js 5.x
62-
node-version: "5.12"
63-
64-
65-
- name: Node.js 6.x
66-
node-version: "6.17"
67-
68-
69-
- name: Node.js 7.x
70-
node-version: "7.10"
71-
72-
73-
- name: Node.js 8.x
74-
node-version: "8.17"
75-
76-
77-
- name: Node.js 9.x
78-
node-version: "9.11"
79-
80-
81-
- name: Node.js 10.x
82-
node-version: "10.24"
83-
84-
85-
- name: Node.js 11.x
86-
node-version: "11.15"
87-
88-
89-
- name: Node.js 12.x
90-
node-version: "12.22"
91-
92-
93-
- name: Node.js 13.x
94-
node-version: "13.14"
95-
96-
97-
- name: Node.js 14.x
98-
node-version: "14.20"
99-
100-
- name: Node.js 15.x
101-
node-version: "15.14"
102-
103-
- name: Node.js 16.x
104-
node-version: "16.20"
105-
106-
- name: Node.js 17.x
107-
node-version: "17.9"
108-
109-
- name: Node.js 18.x
110-
node-version: "18.15"
111-
112-
- name: Node.js 19.x
113-
node-version: "19.7"
114-
14+
node-version:
15+
- 18.x
11516
steps:
116-
- uses: actions/checkout@v3
117-
118-
- name: Install Node.js ${{ matrix.node-version }}
119-
shell: bash -eo pipefail -l {0}
120-
run: |
121-
nvm install --default ${{ matrix.node-version }}
122-
dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH"
123-
124-
- name: Configure npm
125-
run: |
126-
npm config set loglevel error
127-
if [[ "$(npm config get package-lock)" == "true" ]]; then
128-
npm config set package-lock false
129-
else
130-
npm config set shrinkwrap false
131-
fi
132-
133-
- name: Install npm module(s) ${{ matrix.npm-i }}
134-
run: npm install --save-dev ${{ matrix.npm-i }}
135-
if: matrix.npm-i != ''
136-
137-
- name: Remove non-test dependencies
138-
run: npm rm --silent --save-dev connect-redis
139-
140-
- name: Setup Node.js version-specific dependencies
141-
shell: bash
142-
run: |
143-
# eslint for linting
144-
# - remove on Node.js < 12
145-
if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 12 ]]; then
146-
node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \
147-
grep -E '^eslint(-|$)' | \
148-
sort -r | \
149-
xargs -n1 npm rm --silent --save-dev
150-
fi
151-
152-
- name: Install Node.js dependencies
153-
run: npm install
154-
155-
- name: List environment
156-
id: list_env
157-
shell: bash
158-
run: |
159-
echo "node@$(node -v)"
160-
echo "npm@$(npm -v)"
161-
npm -s ls ||:
162-
(npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT"
163-
164-
- name: Run tests
165-
shell: bash
166-
run: |
167-
npm run test-ci
168-
cp coverage/lcov.info "coverage/${{ matrix.name }}.lcov"
169-
170-
- name: Lint code
171-
if: steps.list_env.outputs.eslint != ''
172-
run: npm run lint
173-
174-
- name: Collect code coverage
175-
run: |
176-
mv ./coverage "./${{ matrix.name }}"
177-
mkdir ./coverage
178-
mv "./${{ matrix.name }}" "./coverage/${{ matrix.name }}"
179-
180-
- name: Upload code coverage
181-
uses: actions/upload-artifact@v3
182-
with:
183-
name: coverage
184-
path: ./coverage
185-
retention-days: 1
186-
187-
coverage:
188-
needs: test
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
- name: Setup Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
cache: 'npm'
26+
- name: Install dependencies
27+
run: npm ci
28+
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
29+
run: npm audit signatures
30+
test:
31+
name: Fast Tests
18932
runs-on: ubuntu-latest
33+
needs: build
34+
strategy:
35+
matrix:
36+
node-version:
37+
- 18.x
38+
- 19.x
39+
- 20.x
19040
steps:
191-
- uses: actions/checkout@v3
192-
193-
- name: Install lcov
194-
shell: bash
195-
run: sudo apt-get -y install lcov
196-
197-
- name: Collect coverage reports
198-
uses: actions/download-artifact@v3
199-
with:
200-
name: coverage
201-
path: ./coverage
202-
203-
- name: Merge coverage reports
204-
shell: bash
205-
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./coverage/lcov.info
206-
207-
- name: Upload coverage report
208-
uses: coverallsapp/github-action@master
209-
with:
210-
github-token: ${{ secrets.GITHUB_TOKEN }}
41+
- name: Checkout
42+
uses: actions/checkout@v3
43+
with:
44+
fetch-depth: 0
45+
- name: Use Node.js ${{ matrix.node-version }}
46+
uses: actions/setup-node@v3
47+
with:
48+
node-version: ${{ matrix.node-version }}
49+
cache: 'npm'
50+
- run: npm ci
51+
- run: npm test
52+
release:
53+
name: Release
54+
if: github.ref == 'refs/heads/main' && success()
55+
needs: [build, test]
56+
runs-on: ubuntu-latest
57+
strategy:
58+
matrix:
59+
node-version:
60+
- 20.x
61+
steps:
62+
- name: Checkout
63+
uses: actions/checkout@v3
64+
- name: Semantic Release
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
68+
run: npx semantic-release

History.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
1-
unreleased
2-
==========
3-
1+
5.0.0 / 2023-12-11
2+
===================
3+
4+
* deps: removed safe-buffer
5+
- engine: node >= v18.19.0
6+
- Use Node Buffer instead of `safe-buffer`
7+
8+
- BREAKING CHANGE: upgraded from 0.1.7. Route mapping changes e.g. /*, /foo/ handling /foo, no longer work
9+
- See https://github.com/pillarjs/path-to-regexp for documentation
10+
* deps: removed array-flatten
11+
- Replaced with Array.prototype.flat
12+
- Removed `utils.flatten`
13+
14+
15+
* deps: removed mocha
16+
- Replaced mocha with Node Test Runner
17+
- Removed `nyc`
18+
* Use ES Import for tests
19+
- Renamed tests with `.mjs` file extension
20+
- Renamed tests with Pascal Casing
421
* Fix routing requests without method
522
623
- Fix strict json error message on Node.js 19+
@@ -2950,7 +2967,7 @@ Closes #805
29502967
* Added route `Collection`, ex: `app.get('/user/:id').remove();`
29512968
* Added support for `app.param(fn)` to define param logic
29522969
* Removed `app.param()` support for callback with return value
2953-
* Removed module.parent check from express(1) generated app. Closes #670
2970+
* Removed require.main check from express(1) generated app. Closes #670
29542971
* Refactored router. Closes #639
29552972

29562973
2.3.6 / 2011-05-20

examples/auth/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ hash({ password: 'foobar' }, function (err, pass, salt, hash) {
5858
// Authenticate using our plain-object database of doom!
5959

6060
function authenticate(name, pass, fn) {
61-
if (!module.parent) console.log('authenticating %s:%s', name, pass);
61+
if (!require.main) console.log('authenticating %s:%s', name, pass);
6262
var user = users[name];
6363
// query the db for the given username
6464
if (!user) return fn(null, null)
@@ -127,7 +127,8 @@ app.post('/login', function (req, res, next) {
127127
});
128128

129129
/* istanbul ignore next */
130-
if (!module.parent) {
131-
app.listen(3000);
132-
console.log('Express started on port 3000');
130+
if (!require.main) {
131+
const server = app.listen();
132+
app.close = () => server.close();
133+
console.log(`Express started on port ${server.address().port}`);
133134
}

examples/content-negotiation/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ function format(path) {
4040
app.get('/users', format('./users'));
4141

4242
/* istanbul ignore next */
43-
if (!module.parent) {
44-
app.listen(3000);
45-
console.log('Express started on port 3000');
43+
if (!require.main) {
44+
const server = app.listen();
45+
app.close = () => server.close();
46+
console.log(`Express started on port ${server.address().port}`);
4647
}

examples/cookie-sessions/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ function count(req, res) {
2222
}
2323

2424
/* istanbul ignore next */
25-
if (!module.parent) {
26-
app.listen(3000);
27-
console.log('Express started on port 3000');
25+
if (!require.main) {
26+
const server = app.listen();
27+
app.close = () => server.close();
28+
console.log(`Express started on port ${server.address().port}`);
2829
}

examples/cookies/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ app.post('/', function(req, res){
4343
});
4444

4545
/* istanbul ignore next */
46-
if (!module.parent) {
47-
app.listen(3000);
48-
console.log('Express started on port 3000');
46+
if (!require.main) {
47+
const server = app.listen();
48+
app.close = () => server.close();
49+
console.log(`Express started on port ${server.address().port}`);
4950
}

examples/downloads/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ app.get('/', function(req, res){
2323

2424
// /files/* is accessed via req.params[0]
2525
// but here we name it :file
26-
app.get('/files/:file(*)', function(req, res, next){
26+
app.get('/files/:file(.*)', function(req, res, next){
2727
res.download(req.params.file, { root: FILES_DIR }, function (err) {
2828
if (!err) return; // file sent
2929
if (err.status !== 404) return next(err); // non-404 error
@@ -34,7 +34,8 @@ app.get('/files/:file(*)', function(req, res, next){
3434
});
3535

3636
/* istanbul ignore next */
37-
if (!module.parent) {
38-
app.listen(3000);
39-
console.log('Express started on port 3000');
37+
if (!require.main) {
38+
const server = app.listen();
39+
app.close = () => server.close();
40+
console.log(`Express started on port ${server.address().port}`);
4041
}

examples/ejs/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ app.get('/', function(req, res){
5151
});
5252

5353
/* istanbul ignore next */
54-
if (!module.parent) {
55-
app.listen(3000);
56-
console.log('Express started on port 3000');
54+
if (!require.main) {
55+
const server = app.listen();
56+
app.close = () => server.close();
57+
console.log(`Express started on port ${server.address().port}`);
5758
}

0 commit comments

Comments
 (0)