From 1b69224219dfe66b75ee048f891c97da85113e14 Mon Sep 17 00:00:00 2001 From: William Killerud Date: Fri, 15 Nov 2024 14:31:41 +0100 Subject: [PATCH] fix: update dependencies (#460) BREAKING CHANGE: Requires Node >=20.5.0. Uses `text/javascript` instead of `application/javascript` as mimetype. --- .github/workflows/publish.yml | 2 +- .github/workflows/test.yml | 2 +- lib/multipart/parser.js | 6 ++-- package.json | 26 +++++++------- .../test/multipart/parser.js.test.cjs | 36 +++++++++++-------- test/classes/asset.js | 4 +-- test/classes/http-outgoing.js | 8 ++--- 7 files changed, 43 insertions(+), 41 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0a15f421..18a51c77 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -22,7 +22,7 @@ jobs: - uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 22 - run: npm install diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b935cc70..5fda0e57 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] - node-version: [18, 20] + node-version: [20, 22] runs-on: ${{ matrix.os }} steps: diff --git a/lib/multipart/parser.js b/lib/multipart/parser.js index efbc3ad3..f1e79808 100644 --- a/lib/multipart/parser.js +++ b/lib/multipart/parser.js @@ -3,7 +3,7 @@ import HttpError from "http-errors"; import Busboy from "busboy"; import abslog from "abslog"; import ssri from "ssri"; -import tar from "tar"; +import { Parser } from "tar"; import { createFilePathToAsset } from "../utils/path-builders-fs.js"; import FormField from "./form-field.js"; @@ -131,9 +131,9 @@ const MultipartParser = class MultipartParser { file.emit("error", new HttpError.PayloadTooLarge()); }); - const extract = new tar.Parse({ + const extract = new Parser({ strict: true, - onentry: (entry) => { + onReadEntry: (entry) => { // Entries not supported must be thrown // away for extraction to continue if (entry.type.toLowerCase() !== "file") { diff --git a/package.json b/package.json index 5b3ca25c..9e3ba024 100644 --- a/package.json +++ b/package.json @@ -25,36 +25,36 @@ "author": "", "license": "MIT", "dependencies": { - "@eik/common": "4.1.1", + "@eik/common": "5.0.0", "@eik/sink": "1.2.5", - "@eik/sink-file-system": "1.0.1", - "@eik/sink-memory": "1.1.2", + "@eik/sink-file-system": "2.0.0", + "@eik/sink-memory": "2.0.0", "@metrics/client": "2.5.4", "abslog": "2.4.4", "busboy": "1.6.0", "http-errors": "2.0.0", - "mime": "3.0.0", + "mime": "4.0.4", "original-url": "1.2.3", "semver": "7.6.3", - "ssri": "10.0.6", - "tar": "6.2.1", - "unique-slug": "4.0.0" + "ssri": "12.0.0", + "tar": "7.4.3", + "unique-slug": "5.0.0" }, "devDependencies": { - "@eik/eslint-config": "1.0.4", + "@eik/eslint-config": "1.0.5", "@eik/prettier-config": "1.0.1", "@eik/semantic-release-config": "1.0.0", "@eik/typescript-config": "1.0.0", "@types/readable-stream": "4.0.18", - "eslint": "9.13.0", + "eslint": "9.14.0", "form-data": "4.0.1", "mkdirp": "3.0.1", "node-fetch": "3.3.2", - "npm-run-all2": "5.0.2", + "npm-run-all2": "7.0.1", "prettier": "3.3.3", "rimraf": "6.0.1", - "semantic-release": "24.1.2", - "tap": "18.8.0", - "typescript": "5.5.4" + "semantic-release": "24.2.0", + "tap": "21.0.1", + "typescript": "5.6.3" } } diff --git a/tap-snapshots/test/multipart/parser.js.test.cjs b/tap-snapshots/test/multipart/parser.js.test.cjs index 6cb208bd..51cd37ee 100644 --- a/tap-snapshots/test/multipart/parser.js.test.cjs +++ b/tap-snapshots/test/multipart/parser.js.test.cjs @@ -4,15 +4,17 @@ * 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/multipart/parser.js > TAP > Parser() - Request contains multiple files and fields > parsed request should match snapshot 1`] = ` +"use strict"; +exports[ + `test/multipart/parser.js > TAP > Parser() - Request contains multiple files and fields > parsed request should match snapshot 1` +] = ` Array [ FormFile { "_name": "tgz", "_value": Array [ Asset { "_integrity": "sha512-i1oU4MCMKNS1akPh2DGG4w4SKDxj0mg7XW7jvIGx+/6wRxWREm5CCLhugpsnzc8MvhBW1h/7AT3nINtGT++nTQ==", - "_mimeType": "application/javascript", + "_mimeType": "text/javascript", "_name": "buz", "_org": "biz", "_pathname": "/ie11/index.js", @@ -32,7 +34,7 @@ Array [ }, Asset { "_integrity": "sha512-lq9ovpg4+LD6vF+yOFaZTnuT43fVPmCDg9FjFKl4TM3/UI8TrXeQa3WlpkoFB1WoucVwQcP9pFvZrBjtts4uHA==", - "_mimeType": "application/javascript", + "_mimeType": "text/javascript", "_name": "buz", "_org": "biz", "_pathname": "/main/index.js", @@ -85,7 +87,7 @@ Array [ "_value": Array [ Asset { "_integrity": "sha512-i1oU4MCMKNS1akPh2DGG4w4SKDxj0mg7XW7jvIGx+/6wRxWREm5CCLhugpsnzc8MvhBW1h/7AT3nINtGT++nTQ==", - "_mimeType": "application/javascript", + "_mimeType": "text/javascript", "_name": "buz", "_org": "biz", "_pathname": "/ie11/index.js", @@ -105,7 +107,7 @@ Array [ }, Asset { "_integrity": "sha512-lq9ovpg4+LD6vF+yOFaZTnuT43fVPmCDg9FjFKl4TM3/UI8TrXeQa3WlpkoFB1WoucVwQcP9pFvZrBjtts4uHA==", - "_mimeType": "application/javascript", + "_mimeType": "text/javascript", "_name": "buz", "_org": "biz", "_pathname": "/main/index.js", @@ -146,9 +148,11 @@ Array [ ], }, ] -` +`; -exports[`test/multipart/parser.js > TAP > Parser() - Request contains only fields > parsed request should match snapshot 1`] = ` +exports[ + `test/multipart/parser.js > TAP > Parser() - Request contains only fields > parsed request should match snapshot 1` +] = ` Array [ FormField { "_name": "foo", @@ -159,16 +163,18 @@ Array [ "_value": "value-bar", }, ] -` +`; -exports[`test/multipart/parser.js > TAP > Parser() - Request contains only files > parsed request should match snapshot 1`] = ` +exports[ + `test/multipart/parser.js > TAP > Parser() - Request contains only files > parsed request should match snapshot 1` +] = ` Array [ FormFile { "_name": "tgz", "_value": Array [ Asset { "_integrity": "sha512-i1oU4MCMKNS1akPh2DGG4w4SKDxj0mg7XW7jvIGx+/6wRxWREm5CCLhugpsnzc8MvhBW1h/7AT3nINtGT++nTQ==", - "_mimeType": "application/javascript", + "_mimeType": "text/javascript", "_name": "buz", "_org": "biz", "_pathname": "/ie11/index.js", @@ -188,7 +194,7 @@ Array [ }, Asset { "_integrity": "sha512-lq9ovpg4+LD6vF+yOFaZTnuT43fVPmCDg9FjFKl4TM3/UI8TrXeQa3WlpkoFB1WoucVwQcP9pFvZrBjtts4uHA==", - "_mimeType": "application/javascript", + "_mimeType": "text/javascript", "_name": "buz", "_org": "biz", "_pathname": "/main/index.js", @@ -233,7 +239,7 @@ Array [ "_value": Array [ Asset { "_integrity": "sha512-i1oU4MCMKNS1akPh2DGG4w4SKDxj0mg7XW7jvIGx+/6wRxWREm5CCLhugpsnzc8MvhBW1h/7AT3nINtGT++nTQ==", - "_mimeType": "application/javascript", + "_mimeType": "text/javascript", "_name": "buz", "_org": "biz", "_pathname": "/ie11/index.js", @@ -253,7 +259,7 @@ Array [ }, Asset { "_integrity": "sha512-lq9ovpg4+LD6vF+yOFaZTnuT43fVPmCDg9FjFKl4TM3/UI8TrXeQa3WlpkoFB1WoucVwQcP9pFvZrBjtts4uHA==", - "_mimeType": "application/javascript", + "_mimeType": "text/javascript", "_name": "buz", "_org": "biz", "_pathname": "/main/index.js", @@ -294,4 +300,4 @@ Array [ ], }, ] -` +`; diff --git a/test/classes/asset.js b/test/classes/asset.js index e9c42bae..695114ba 100644 --- a/test/classes/asset.js +++ b/test/classes/asset.js @@ -45,7 +45,7 @@ tap.test("Asset() - Set values to the arguments on the constructor", (t) => { ); t.equal( obj.mimeType, - "application/javascript", + "text/javascript", '.mimeType should contain value matching type of file set on "pathname"', ); t.equal( @@ -141,7 +141,7 @@ tap.test("Asset() - Stringify object to JSON", (t) => { ); t.equal( o.mimeType, - "application/javascript", + "text/javascript", '.mimeType should contain value matching type of file set on "pathname" on the origin object', ); t.equal(o.type, "pkg", ".type should contain value set on origin object"); diff --git a/test/classes/http-outgoing.js b/test/classes/http-outgoing.js index 3b984be9..efeb7536 100644 --- a/test/classes/http-outgoing.js +++ b/test/classes/http-outgoing.js @@ -73,12 +73,8 @@ tap.test("HttpOutgoing() - Set .location to legal value", (t) => { tap.test("HttpOutgoing() - Set .mimeType to legal value", (t) => { const obj = new HttpOutgoing(); - obj.mimeType = "application/javascript"; - t.equal( - obj.mimeType, - "application/javascript", - ".location should be the set value", - ); + obj.mimeType = "text/javascript"; + t.equal(obj.mimeType, "text/javascript", ".location should be the set value"); t.end(); });