Skip to content

Commit 1a5a200

Browse files
jsumnersgurgundaysynapse
authored
Merge next into master (#241)
* update for Fastify v5 (#236) * update for v5 * add pre commit * upgrade for fastify 5 (#238) Signed-off-by: Cristian Barlutiu <[email protected]> * update for Fastify v5 (#236) * update for v5 * add pre commit * upgrade for fastify 5 (#238) Signed-off-by: Cristian Barlutiu <[email protected]> * update deps and tests --------- Signed-off-by: Cristian Barlutiu <[email protected]> Co-authored-by: Gürgün Dayıoğlu <[email protected]> Co-authored-by: Cristian Barlutiu <[email protected]>
1 parent 026d538 commit 1a5a200

File tree

4 files changed

+40
-36
lines changed

4 files changed

+40
-36
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ on:
1717

1818
jobs:
1919
test:
20-
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3
20+
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v4.1.0
2121
with:
2222
lint: true
2323
license-check: true

.taprc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
ts: false
2-
jsx: false
3-
flow: false
4-
coverage: true
5-
61
files:
72
- test/**/*.js
3+
plugin:
4+
- "!@tapjs/typescript"

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@
2727
},
2828
"homepage": "https://github.com/fastify/fastify-plugin#readme",
2929
"devDependencies": {
30-
"@fastify/type-provider-typebox": "^4.0.0",
31-
"@types/node": "^20.1.0",
32-
"fastify": "^4.0.1",
30+
"@fastify/pre-commit": "^2.1.0",
31+
"@fastify/type-provider-typebox": "^5.0.0-pre.fv5.1",
32+
"@types/node": "^20.11.20",
33+
"fastify": "^5.0.0-alpha.2",
3334
"proxyquire": "^2.1.3",
34-
"standard": "^17.0.0",
35-
"tap": "^16.0.1",
35+
"standard": "^17.1.0",
36+
"tap": "^18.7.0",
3637
"tsd": "^0.31.0"
3738
}
3839
}

test/test.js

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const test = t.test
66
const fp = require('../plugin')
77
const Fastify = require('fastify')
88

9+
const pkg = require('../package.json')
10+
911
test('fastify-plugin is a function', t => {
1012
t.plan(1)
1113
t.type(fp, 'function')
@@ -206,12 +208,12 @@ test('should check fastify dependency graph - plugin', t => {
206208
const fastify = Fastify()
207209

208210
fastify.register(fp((fastify, opts, next) => next(), {
209-
fastify: '4.x',
211+
fastify: '5.x',
210212
name: 'plugin1-name'
211213
}))
212214

213215
fastify.register(fp((fastify, opts, next) => next(), {
214-
fastify: '4.x',
216+
fastify: '5.x',
215217
name: 'test',
216218
dependencies: ['plugin1-name', 'plugin2-name']
217219
}))
@@ -226,12 +228,12 @@ test('should check fastify dependency graph - decorate', t => {
226228
const fastify = Fastify()
227229

228230
fastify.decorate('plugin1', fp((fastify, opts, next) => next(), {
229-
fastify: '4.x',
231+
fastify: '5.x',
230232
name: 'plugin1-name'
231233
}))
232234

233235
fastify.register(fp((fastify, opts, next) => next(), {
234-
fastify: '4.x',
236+
fastify: '5.x',
235237
name: 'test',
236238
decorators: { fastify: ['plugin1', 'plugin2'] }
237239
}))
@@ -246,12 +248,12 @@ test('should check fastify dependency graph - decorateReply', t => {
246248
const fastify = Fastify()
247249

248250
fastify.decorateReply('plugin1', fp((fastify, opts, next) => next(), {
249-
fastify: '4.x',
251+
fastify: '5.x',
250252
name: 'plugin1-name'
251253
}))
252254

253255
fastify.register(fp((fastify, opts, next) => next(), {
254-
fastify: '4.x',
256+
fastify: '5.x',
255257
name: 'test',
256258
decorators: { reply: ['plugin1', 'plugin2'] }
257259
}))
@@ -311,20 +313,24 @@ test('should check dependencies when encapsulated', t => {
311313
})
312314
})
313315

314-
test('should check version when encapsulated', t => {
315-
t.plan(1)
316-
const fastify = Fastify()
316+
test(
317+
'should check version when encapsulated',
318+
{ skip: /\d-.+/.test(pkg.devDependencies.fastify) },
319+
t => {
320+
t.plan(1)
321+
const fastify = Fastify()
317322

318-
fastify.register(fp((fastify, opts, next) => next(), {
319-
name: 'test',
320-
fastify: '<=2.10.0',
321-
encapsulate: true
322-
}))
323+
fastify.register(fp((fastify, opts, next) => next(), {
324+
name: 'test',
325+
fastify: '<=2.10.0',
326+
encapsulate: true
327+
}))
323328

324-
fastify.ready(err => {
325-
t.match(err.message, /fastify-plugin: test - expected '<=2.10.0' fastify version, '\d.\d+.\d+' is installed/)
326-
})
327-
})
329+
fastify.ready(err => {
330+
t.match(err.message, /fastify-plugin: test - expected '<=2.10.0' fastify version, '\d.\d+.\d+' is installed/)
331+
})
332+
}
333+
)
328334

329335
test('should check decorators when encapsulated', t => {
330336
t.plan(1)
@@ -333,7 +339,7 @@ test('should check decorators when encapsulated', t => {
333339
fastify.decorate('plugin1', 'foo')
334340

335341
fastify.register(fp((fastify, opts, next) => next(), {
336-
fastify: '4.x',
342+
fastify: '5.x',
337343
name: 'test',
338344
encapsulate: true,
339345
decorators: { fastify: ['plugin1', 'plugin2'] }
@@ -352,14 +358,14 @@ test('plugin name when encapsulated', async t => {
352358
})
353359

354360
fastify.register(fp(getFn('hello'), {
355-
fastify: '4.x',
361+
fastify: '5.x',
356362
name: 'hello',
357363
encapsulate: true
358364
}))
359365

360366
fastify.register(function plugin (fastify, opts, next) {
361367
fastify.register(fp(getFn('deep'), {
362-
fastify: '4.x',
368+
fastify: '5.x',
363369
name: 'deep',
364370
encapsulate: true
365371
}))
@@ -368,25 +374,25 @@ test('plugin name when encapsulated', async t => {
368374
t.equal(fastify.pluginName, 'deep-deep', 'should be deep-deep')
369375

370376
fastify.register(fp(getFn('deep-deep-deep'), {
371-
fastify: '4.x',
377+
fastify: '5.x',
372378
name: 'deep-deep-deep',
373379
encapsulate: true
374380
}))
375381

376382
fastify.register(fp(getFn('deep-deep -> not-encapsulated-2'), {
377-
fastify: '4.x',
383+
fastify: '5.x',
378384
name: 'not-encapsulated-2'
379385
}))
380386

381387
next()
382388
}, {
383-
fastify: '4.x',
389+
fastify: '5.x',
384390
name: 'deep-deep',
385391
encapsulate: true
386392
}))
387393

388394
fastify.register(fp(getFn('plugin -> not-encapsulated'), {
389-
fastify: '4.x',
395+
fastify: '5.x',
390396
name: 'not-encapsulated'
391397
}))
392398

0 commit comments

Comments
 (0)