From 1adfe27f9dcdb7879ed08b2e0cf37f91d0814c32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCrg=C3=BCn=20Day=C4=B1o=C4=9Flu?= Date: Mon, 22 Apr 2024 14:45:33 +0200 Subject: [PATCH 1/4] update to v5 (#423) --- .github/workflows/ci.yml | 2 +- .gitignore | 3 ++ .taprc | 9 +--- index.js | 1 + package.json | 42 +++++++++---------- .../test/test-ejs-with-snapshot.js.test.cjs | 26 ------------ test/{ => snap}/test-ejs-with-snapshot.js | 10 ++--- 7 files changed, 33 insertions(+), 60 deletions(-) delete mode 100644 tap-snapshots/test/test-ejs-with-snapshot.js.test.cjs rename test/{ => snap}/test-ejs-with-snapshot.js (96%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7b002766..5395d92e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ on: jobs: test: - uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3 + uses: fastify/workflows/.github/workflows/plugins-ci.yml@v4.1.0 with: license-check: true lint: true diff --git a/.gitignore b/.gitignore index 1bb63f02..04945309 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,9 @@ yarn-error.log* lerna-debug.log* .pnpm-debug.log* +out/ +tap-snapshots/ + # Diagnostic reports (https://nodejs.org/api/report.html) report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json diff --git a/.taprc b/.taprc index 0110bb6c..b5458019 100644 --- a/.taprc +++ b/.taprc @@ -1,8 +1,3 @@ -ts: false -jsx: false -flow: false -coverage: true -nyc-arg: [--exclude=out] - +disable-coverage: true files: - - test/**/*.{js,mjs} + - test/*.{js,mjs} diff --git a/index.js b/index.js index c2cad445..0ff3bdb0 100644 --- a/index.js +++ b/index.js @@ -607,6 +607,7 @@ async function fastifyView (fastify, opts) { renderAsync = engine.renderAsync.bind(engine) } + /* c8 ignore next */ if (opts?.async ?? globalOptions.async) { return renderAsync(page, data, config) } else { diff --git a/package.json b/package.json index 50d53394..bce41b91 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "example-with-options": "node examples/example-ejs-with-some-options.js", "example-typescript": "npx ts-node types/index.test-d.ts", "lint": "standard", - "test-with-snapshot": "cross-env TAP_SNAPSHOT=1 tap test/test-ejs-with-snapshot.js", - "test": "npm run test:unit && npm run test:typescript", + "test-with-snapshot": "cross-env TAP_SNAPSHOT=1 tap test/snap/*", + "test": "npm run test:unit && npm run test-with-snapshot && npm run test:typescript", "test:unit": "tap", "test:typescript": "tsd" }, @@ -40,33 +40,33 @@ }, "homepage": "https://github.com/fastify/point-of-view#readme", "dependencies": { - "fastify-plugin": "^4.0.0", + "fastify-plugin": "^4.5.1", "toad-cache": "^3.7.0" }, "devDependencies": { - "@fastify/pre-commit": "^2.0.2", - "@types/node": "^20.1.0", + "@fastify/pre-commit": "^2.1.0", + "@types/node": "^20.12.7", "art-template": "^4.13.2", "autocannon": "^7.15.0", - "cross-env": "^7.0.2", + "cross-env": "^7.0.3", "dot": "^1.1.3", - "ejs": "^3.1.8", - "eta": "^3.0.3", - "express": "^4.17.1", - "fastify": "^4.0.0-rc.2", - "handlebars": "^4.7.6", + "ejs": "^3.1.10", + "eta": "^3.4.0", + "express": "^4.19.2", + "fastify": "^4.26.2", + "handlebars": "^4.7.8", "html-minifier-terser": "^7.2.0", - "liquidjs": "^10.0.0", - "mustache": "^4.0.1", - "nunjucks": "^3.2.1", - "pino": "^8.0.0", - "pug": "^3.0.0", - "simple-get": "^4.0.0", - "split2": "^4.0.0", - "standard": "^17.0.0", - "tap": "^16.0.0", + "liquidjs": "^10.11.0", + "mustache": "^4.2.0", + "nunjucks": "^3.2.4", + "pino": "^8.20.0", + "pug": "^3.0.2", + "simple-get": "^4.0.1", + "split2": "^4.2.0", + "standard": "^17.1.0", + "tap": "^18.7.2", "tsd": "^0.31.0", - "twig": "^1.13.3" + "twig": "^1.17.1" }, "pre-commit": [ "lint", diff --git a/tap-snapshots/test/test-ejs-with-snapshot.js.test.cjs b/tap-snapshots/test/test-ejs-with-snapshot.js.test.cjs deleted file mode 100644 index 931e80a6..00000000 --- a/tap-snapshots/test/test-ejs-with-snapshot.js.test.cjs +++ /dev/null @@ -1,26 +0,0 @@ -/* IMPORTANT - * This snapshot file is auto-generated, but designed for humans. - * It should be checked into source control and tracked carefully. - * Re-generate by setting TAP_SNAPSHOT=1 and running tests. - * Make sure to inspect the output below. Do not ignore changes! - */ -'use strict' -exports['test/test-ejs-with-snapshot.js TAP reply.view with ejs engine, template folder specified, include files (ejs and html) used in template, includeViewExtension property as true; requires TAP snapshots enabled > output 1'] = ` -

text


Other EJS pages with includes:

-` - -exports['test/test-ejs-with-snapshot.js TAP reply.view with ejs engine, templates with folder specified, include files and attributes; requires TAP snapshots enabled; home > output 1'] = ` -

Hello from EJS Templates


-` - -exports['test/test-ejs-with-snapshot.js TAP reply.view with ejs engine, templates with folder specified, include files and attributes; requires TAP snapshots enabled; page with includes > output 1'] = ` -
Sample header (ejs)

Hello from EJS Templates

Sample footer (html) - Back to Home
-` - -exports['test/test-ejs-with-snapshot.js TAP reply.view with ejs engine, templates with folder specified, include files and attributes; requires TAP snapshots enabled; page with one attribute missing > output 1'] = ` -undefined -` - -exports['test/test-ejs-with-snapshot.js TAP reply.view with ejs engine, templates with folder specified, include files and attributes; requires TAP snapshots enabled; page with one include missing > output 1'] = ` -undefined -` diff --git a/test/test-ejs-with-snapshot.js b/test/snap/test-ejs-with-snapshot.js similarity index 96% rename from test/test-ejs-with-snapshot.js rename to test/snap/test-ejs-with-snapshot.js index cdecb3e0..77615078 100644 --- a/test/test-ejs-with-snapshot.js +++ b/test/snap/test-ejs-with-snapshot.js @@ -18,7 +18,7 @@ test('reply.view with ejs engine, template folder specified, include files (ejs const data = { text: 'text' } - fastify.register(require('../index'), { + fastify.register(require('../../index'), { engine: { ejs }, @@ -62,7 +62,7 @@ test('reply.view with ejs engine, templates with folder specified, include files const data = { text: 'Hello from EJS Templates' } - fastify.register(require('../index'), { + fastify.register(require('../../index'), { engine: { ejs }, @@ -106,7 +106,7 @@ test('reply.view with ejs engine, templates with folder specified, include files const data = { text: 'Hello from EJS Templates' } - fastify.register(require('../index'), { + fastify.register(require('../../index'), { engine: { ejs }, @@ -150,7 +150,7 @@ test('reply.view with ejs engine, templates with folder specified, include files const data = { text: 'Hello from EJS Templates' } - fastify.register(require('../index'), { + fastify.register(require('../../index'), { engine: { ejs }, @@ -194,7 +194,7 @@ test('reply.view with ejs engine, templates with folder specified, include files const data = { text: 'Hello from EJS Templates' } - fastify.register(require('../index'), { + fastify.register(require('../../index'), { engine: { ejs }, From ddff2f92d2212862676dd138d92c3c17f3c7db95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCrg=C3=BCn=20Day=C4=B1o=C4=9Flu?= Date: Mon, 22 Apr 2024 14:45:33 +0200 Subject: [PATCH 2/4] update to v5 (#423) --- .github/workflows/ci.yml | 2 +- .gitignore | 3 ++ .taprc | 9 +--- index.js | 1 + package.json | 42 +++++++++---------- .../test/test-ejs-with-snapshot.js.test.cjs | 26 ------------ test/{ => snap}/test-ejs-with-snapshot.js | 10 ++--- 7 files changed, 33 insertions(+), 60 deletions(-) delete mode 100644 tap-snapshots/test/test-ejs-with-snapshot.js.test.cjs rename test/{ => snap}/test-ejs-with-snapshot.js (96%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7b002766..5395d92e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ on: jobs: test: - uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3 + uses: fastify/workflows/.github/workflows/plugins-ci.yml@v4.1.0 with: license-check: true lint: true diff --git a/.gitignore b/.gitignore index 1bb63f02..04945309 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,9 @@ yarn-error.log* lerna-debug.log* .pnpm-debug.log* +out/ +tap-snapshots/ + # Diagnostic reports (https://nodejs.org/api/report.html) report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json diff --git a/.taprc b/.taprc index 0110bb6c..b5458019 100644 --- a/.taprc +++ b/.taprc @@ -1,8 +1,3 @@ -ts: false -jsx: false -flow: false -coverage: true -nyc-arg: [--exclude=out] - +disable-coverage: true files: - - test/**/*.{js,mjs} + - test/*.{js,mjs} diff --git a/index.js b/index.js index 98a26121..c070a602 100644 --- a/index.js +++ b/index.js @@ -614,6 +614,7 @@ async function fastifyView (fastify, opts) { renderAsync = engine.renderAsync.bind(engine) } + /* c8 ignore next */ if (opts?.async ?? globalOptions.async) { return renderAsync(page, data, config) } else { diff --git a/package.json b/package.json index 94a2dfd6..9d34d413 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "example-with-options": "node examples/example-ejs-with-some-options.js", "example-typescript": "npx ts-node types/index.test-d.ts", "lint": "standard", - "test-with-snapshot": "cross-env TAP_SNAPSHOT=1 tap test/test-ejs-with-snapshot.js", - "test": "npm run test:unit && npm run test:typescript", + "test-with-snapshot": "cross-env TAP_SNAPSHOT=1 tap test/snap/*", + "test": "npm run test:unit && npm run test-with-snapshot && npm run test:typescript", "test:unit": "tap", "test:typescript": "tsd" }, @@ -40,33 +40,33 @@ }, "homepage": "https://github.com/fastify/point-of-view#readme", "dependencies": { - "fastify-plugin": "^4.0.0", + "fastify-plugin": "^4.5.1", "toad-cache": "^3.7.0" }, "devDependencies": { - "@fastify/pre-commit": "^2.0.2", - "@types/node": "^20.1.0", + "@fastify/pre-commit": "^2.1.0", + "@types/node": "^20.12.7", "art-template": "^4.13.2", "autocannon": "^7.15.0", - "cross-env": "^7.0.2", + "cross-env": "^7.0.3", "dot": "^1.1.3", - "ejs": "^3.1.8", - "eta": "^3.0.3", - "express": "^4.17.1", - "fastify": "^4.0.0-rc.2", - "handlebars": "^4.7.6", + "ejs": "^3.1.10", + "eta": "^3.4.0", + "express": "^4.19.2", + "fastify": "^4.26.2", + "handlebars": "^4.7.8", "html-minifier-terser": "^7.2.0", - "liquidjs": "^10.0.0", - "mustache": "^4.0.1", - "nunjucks": "^3.2.1", - "pino": "^9.2.0", - "pug": "^3.0.0", - "simple-get": "^4.0.0", - "split2": "^4.0.0", - "standard": "^17.0.0", - "tap": "^16.0.0", + "liquidjs": "^10.11.0", + "mustache": "^4.2.0", + "nunjucks": "^3.2.4", + "pino": "^8.20.0", + "pug": "^3.0.2", + "simple-get": "^4.0.1", + "split2": "^4.2.0", + "standard": "^17.1.0", + "tap": "^18.7.2", "tsd": "^0.31.0", - "twig": "^1.13.3" + "twig": "^1.17.1" }, "pre-commit": [ "lint", diff --git a/tap-snapshots/test/test-ejs-with-snapshot.js.test.cjs b/tap-snapshots/test/test-ejs-with-snapshot.js.test.cjs deleted file mode 100644 index 931e80a6..00000000 --- a/tap-snapshots/test/test-ejs-with-snapshot.js.test.cjs +++ /dev/null @@ -1,26 +0,0 @@ -/* IMPORTANT - * This snapshot file is auto-generated, but designed for humans. - * It should be checked into source control and tracked carefully. - * Re-generate by setting TAP_SNAPSHOT=1 and running tests. - * Make sure to inspect the output below. Do not ignore changes! - */ -'use strict' -exports['test/test-ejs-with-snapshot.js TAP reply.view with ejs engine, template folder specified, include files (ejs and html) used in template, includeViewExtension property as true; requires TAP snapshots enabled > output 1'] = ` -

text


Other EJS pages with includes:

  • Normal page, here
  • One include not exist, here (to raise errors)
  • One attribute not exist, here (to raise errors)
-` - -exports['test/test-ejs-with-snapshot.js TAP reply.view with ejs engine, templates with folder specified, include files and attributes; requires TAP snapshots enabled; home > output 1'] = ` -

Hello from EJS Templates


-` - -exports['test/test-ejs-with-snapshot.js TAP reply.view with ejs engine, templates with folder specified, include files and attributes; requires TAP snapshots enabled; page with includes > output 1'] = ` -
Sample header (ejs)

Hello from EJS Templates

Sample footer (html) - Back to Home
-` - -exports['test/test-ejs-with-snapshot.js TAP reply.view with ejs engine, templates with folder specified, include files and attributes; requires TAP snapshots enabled; page with one attribute missing > output 1'] = ` -undefined -` - -exports['test/test-ejs-with-snapshot.js TAP reply.view with ejs engine, templates with folder specified, include files and attributes; requires TAP snapshots enabled; page with one include missing > output 1'] = ` -undefined -` diff --git a/test/test-ejs-with-snapshot.js b/test/snap/test-ejs-with-snapshot.js similarity index 96% rename from test/test-ejs-with-snapshot.js rename to test/snap/test-ejs-with-snapshot.js index cdecb3e0..77615078 100644 --- a/test/test-ejs-with-snapshot.js +++ b/test/snap/test-ejs-with-snapshot.js @@ -18,7 +18,7 @@ test('reply.view with ejs engine, template folder specified, include files (ejs const data = { text: 'text' } - fastify.register(require('../index'), { + fastify.register(require('../../index'), { engine: { ejs }, @@ -62,7 +62,7 @@ test('reply.view with ejs engine, templates with folder specified, include files const data = { text: 'Hello from EJS Templates' } - fastify.register(require('../index'), { + fastify.register(require('../../index'), { engine: { ejs }, @@ -106,7 +106,7 @@ test('reply.view with ejs engine, templates with folder specified, include files const data = { text: 'Hello from EJS Templates' } - fastify.register(require('../index'), { + fastify.register(require('../../index'), { engine: { ejs }, @@ -150,7 +150,7 @@ test('reply.view with ejs engine, templates with folder specified, include files const data = { text: 'Hello from EJS Templates' } - fastify.register(require('../index'), { + fastify.register(require('../../index'), { engine: { ejs }, @@ -194,7 +194,7 @@ test('reply.view with ejs engine, templates with folder specified, include files const data = { text: 'Hello from EJS Templates' } - fastify.register(require('../index'), { + fastify.register(require('../../index'), { engine: { ejs }, From 1bb75412dae2cebb447e39925830e275d866b356 Mon Sep 17 00:00:00 2001 From: James Sumners Date: Fri, 12 Jul 2024 08:05:09 -0400 Subject: [PATCH 3/4] update fastify deps --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 9d34d413..7f7db54b 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ }, "homepage": "https://github.com/fastify/point-of-view#readme", "dependencies": { - "fastify-plugin": "^4.5.1", + "fastify-plugin": "^5.0.0-pre.fv5.1", "toad-cache": "^3.7.0" }, "devDependencies": { @@ -53,13 +53,13 @@ "ejs": "^3.1.10", "eta": "^3.4.0", "express": "^4.19.2", - "fastify": "^4.26.2", + "fastify": "^5.0.0-alpha.3", "handlebars": "^4.7.8", "html-minifier-terser": "^7.2.0", "liquidjs": "^10.11.0", "mustache": "^4.2.0", "nunjucks": "^3.2.4", - "pino": "^8.20.0", + "pino": "^9.0.0", "pug": "^3.0.2", "simple-get": "^4.0.1", "split2": "^4.2.0", From 3d65473f9df24d27530aa212ad05222f27bfe22a Mon Sep 17 00:00:00 2001 From: James Sumners Date: Fri, 12 Jul 2024 08:08:31 -0400 Subject: [PATCH 4/4] fix test --- test/test-dot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-dot.js b/test/test-dot.js index cb0fc297..0eb8b1db 100644 --- a/test/test-dot.js +++ b/test/test-dot.js @@ -88,7 +88,7 @@ test('reply.view with dot engine .dot file should log WARN if template not found }) const logger = pino({ level: 'warn' }, splitStream) const fastify = Fastify({ - logger + loggerInstance: logger }) const engine = require('dot') engine.log = false