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 fcb4327d..6eab2ea7 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: [20] + node-version: [20, 22] runs-on: ${{ matrix.os }} diff --git a/package.json b/package.json index 620ead82..f3359a6d 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,9 @@ "bin": { "eik": "index.js" }, + "engines": { + "node": ">=20.5.0" + }, "files": [ "CHANGELOG.md", "package.json", @@ -21,10 +24,10 @@ ], "scripts": { "clean": "rimraf .tap node_modules types", - "test": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 60 --disable-coverage", - "test:integration": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 60 --disable-coverage test/integration/**/*.test.mjs", - "test:unit": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 60 --disable-coverage test/*.test.mjs", - "test:tasks": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 60 --disable-coverage test/tasks/*.test.mjs", + "test": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 240 --disable-coverage", + "test:integration": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 240 --disable-coverage test/integration/**/*.test.mjs", + "test:unit": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 240 --disable-coverage test/*.test.mjs", + "test:tasks": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 240 --disable-coverage test/tasks/*.test.mjs", "lint": "eslint .", "lint:fix": "eslint --fix .", "format:check": "prettier -c .", @@ -38,39 +41,40 @@ "author": "", "license": "MIT", "dependencies": { - "@eik/common": "4.1.1", + "@eik/common": "5.0.0", "abslog": "2.4.4", "bytes": "3.1.2", "chalk": "5.3.0", - "date-fns": "3.6.0", + "date-fns": "4.1.0", "form-data": "4.0.1", "gzip-size": "7.0.0", "make-dir": "5.0.0", "ora": "8.1.1", "rimraf": "6.0.1", "semver": "7.6.3", - "ssri": "10.0.6", + "ssri": "12.0.0", "tar": "7.4.3", "yargs": "17.7.2", "yargs-parser": "21.1.1" }, "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/service": "2.3.2", - "@eik/sink-memory": "1.1.2", + "@eik/service": "5.0.0", + "@eik/sink-memory": "2.0.0", "@eik/typescript-config": "1.0.0", + "@types/ssri": "7.1.5", "@types/yargs": "17.0.33", "cross-env": "7.0.3", - "eslint": "9.11.1", - "fastify": "4.28.1", + "eslint": "9.14.0", + "fastify": "5.1.0", "fs-extra": "11.2.0", - "npm-run-all2": "5.0.2", + "npm-run-all2": "7.0.1", "prettier": "3.3.3", - "semantic-release": "24.0.0", + "semantic-release": "24.2.0", "semantic-release-slack-bot": "4.0.2", "tap": "21.0.1", - "typescript": "5.5.4" + "typescript": "5.6.3" } } diff --git a/test/alias.test.mjs b/test/alias.test.mjs index c443764e..ed476c33 100644 --- a/test/alias.test.mjs +++ b/test/alias.test.mjs @@ -14,10 +14,13 @@ const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); beforeEach(async (t) => { - const server = fastify({ logger: false }); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); const memSink = new Sink(); - const service = new EikService({ customSink: memSink }); - server.register(service.api()); + const service = new EikService({ sink: memSink }); + await server.register(service.api()); const address = await server.listen({ host: "127.0.0.1", port: 0, diff --git a/test/integration/alias-legacy.test.mjs b/test/integration/alias-legacy.test.mjs index 90fecd77..16e2b8a1 100644 --- a/test/integration/alias-legacy.test.mjs +++ b/test/integration/alias-legacy.test.mjs @@ -22,10 +22,13 @@ function exec(cmd) { } beforeEach(async (t) => { - const server = fastify({ logger: false }); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); const memSink = new Sink(); - const service = new EikService({ customSink: memSink }); - server.register(service.api()); + const service = new EikService({ sink: memSink }); + await server.register(service.api()); const address = await server.listen({ host: "127.0.0.1", port: 0, @@ -75,9 +78,7 @@ beforeEach(async (t) => { t.context.token = token; }); -afterEach(async (t) => { - await t.context.server.close(); -}); +afterEach((t) => t.context.server.close()); test("eik package-alias ", async (t) => { const { address, token, folder: cwd } = t.context; diff --git a/test/integration/alias.test.mjs b/test/integration/alias.test.mjs index 67766db6..f3bceed2 100644 --- a/test/integration/alias.test.mjs +++ b/test/integration/alias.test.mjs @@ -1,6 +1,6 @@ import fastify from "fastify"; import { promises as fs } from "node:fs"; -import os, { type } from "node:os"; +import os from "node:os"; import { exec as execCallback } from "child_process"; import { join, basename } from "node:path"; import { test, beforeEach, afterEach } from "tap"; @@ -22,10 +22,13 @@ function exec(cmd) { } beforeEach(async (t) => { - const server = fastify({ logger: false }); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); const memSink = new Sink(); - const service = new EikService({ customSink: memSink }); - server.register(service.api()); + const service = new EikService({ sink: memSink }); + await server.register(service.api()); const address = await server.listen({ host: "127.0.0.1", port: 0, @@ -75,9 +78,7 @@ beforeEach(async (t) => { t.context.token = token; }); -afterEach(async (t) => { - await t.context.server.close(); -}); +afterEach((t) => t.context.server.close()); test("packages: eik alias ", async (t) => { const { address, token, folder: cwd } = t.context; diff --git a/test/integration/integrity.test.mjs b/test/integration/integrity.test.mjs index cea8d894..70970069 100644 --- a/test/integration/integrity.test.mjs +++ b/test/integration/integrity.test.mjs @@ -23,9 +23,12 @@ function exec(cmd) { beforeEach(async (t) => { const memSink = new Sink(); - const server = fastify({ logger: false }); - const service = new EikService({ customSink: memSink }); - server.register(service.api()); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); + const service = new EikService({ sink: memSink }); + await server.register(service.api()); const address = await server.listen({ host: "127.0.0.1", port: 0, diff --git a/test/integration/login.test.mjs b/test/integration/login.test.mjs index 6610f8fa..fb7e59c0 100644 --- a/test/integration/login.test.mjs +++ b/test/integration/login.test.mjs @@ -22,9 +22,12 @@ function exec(cmd) { beforeEach(async (t) => { const memSink = new Sink(); - const server = fastify({ logger: false }); - const service = new EikService({ customSink: memSink }); - server.register(service.api()); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); + const service = new EikService({ sink: memSink }); + await server.register(service.api()); const address = await server.listen({ host: "127.0.0.1", port: 0, diff --git a/test/integration/map.test.mjs b/test/integration/map.test.mjs index dda48d60..c47d5b3c 100644 --- a/test/integration/map.test.mjs +++ b/test/integration/map.test.mjs @@ -23,9 +23,12 @@ function exec(cmd) { beforeEach(async (t) => { const memSink = new Sink(); - const server = fastify({ logger: false }); - const service = new EikService({ customSink: memSink }); - server.register(service.api()); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); + const service = new EikService({ sink: memSink }); + await server.register(service.api()); const address = await server.listen({ host: "127.0.0.1", port: 0, diff --git a/test/integration/meta.test.mjs b/test/integration/meta.test.mjs index abc72002..3a97f2ae 100644 --- a/test/integration/meta.test.mjs +++ b/test/integration/meta.test.mjs @@ -23,9 +23,12 @@ function exec(cmd) { beforeEach(async (t) => { const memSink = new Sink(); - const server = fastify({ logger: false }); - const service = new EikService({ customSink: memSink }); - server.register(service.api()); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); + const service = new EikService({ sink: memSink }); + await server.register(service.api()); const address = await server.listen({ host: "127.0.0.1", port: 0, diff --git a/test/integration/package.test.mjs b/test/integration/package.test.mjs index aed69fda..b19f692d 100644 --- a/test/integration/package.test.mjs +++ b/test/integration/package.test.mjs @@ -23,9 +23,12 @@ function exec(cmd) { beforeEach(async (t) => { const memSink = new Sink(); - const server = fastify({ logger: false }); - const service = new EikService({ customSink: memSink }); - server.register(service.api()); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); + const service = new EikService({ sink: memSink }); + await server.register(service.api()); const address = await server.listen({ host: "127.0.0.1", port: 0, @@ -43,9 +46,7 @@ beforeEach(async (t) => { t.context.token = token; }); -afterEach(async (t) => { - await t.context.server.close(); -}); +afterEach((t) => t.context.server.close()); test("eik package : package, details provided by eik.json file", async (t) => { const assets = { diff --git a/test/integration/version.test.mjs b/test/integration/version.test.mjs index 9af4e892..5ebeae72 100644 --- a/test/integration/version.test.mjs +++ b/test/integration/version.test.mjs @@ -29,9 +29,12 @@ function exec(cmd, opts = {}) { beforeEach(async (t) => { const memSink = new Sink(); - const server = fastify({ logger: false }); - const service = new EikService({ customSink: memSink }); - server.register(service.api()); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); + const service = new EikService({ sink: memSink }); + await server.register(service.api()); const address = await server.listen({ host: "127.0.0.1", port: 0, diff --git a/test/integrity.test.mjs b/test/integrity.test.mjs index fda02840..70eb3d32 100644 --- a/test/integrity.test.mjs +++ b/test/integrity.test.mjs @@ -14,10 +14,13 @@ const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); beforeEach(async (t) => { - const server = fastify({ logger: false }); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); const memSink = new Sink(); - const service = new EikService({ customSink: memSink }); - server.register(service.api()); + const service = new EikService({ sink: memSink }); + await server.register(service.api()); const address = await server.listen({ host: "127.0.0.1", port: 0, diff --git a/test/login.test.mjs b/test/login.test.mjs index 67641462..f8ae7114 100644 --- a/test/login.test.mjs +++ b/test/login.test.mjs @@ -15,9 +15,12 @@ const __dirname = dirname(__filename); beforeEach(async (t) => { const memSink = new Sink(); - const server = fastify({ logger: false }); - const service = new EikService({ customSink: memSink }); - server.register(service.api()); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); + const service = new EikService({ sink: memSink }); + await server.register(service.api()); const address = await server.listen({ host: "127.0.0.1", port: 0, diff --git a/test/meta.test.mjs b/test/meta.test.mjs index e336a7b5..2c9e61fd 100644 --- a/test/meta.test.mjs +++ b/test/meta.test.mjs @@ -14,10 +14,13 @@ const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); beforeEach(async (t) => { - const server = fastify({ logger: false }); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); const memSink = new Sink(); - const service = new EikService({ customSink: memSink }); - server.register(service.api()); + const service = new EikService({ sink: memSink }); + await server.register(service.api()); const address = await server.listen({ host: "127.0.0.1", port: 0, diff --git a/test/publish-files-definitions.test.mjs b/test/publish-files-definitions.test.mjs index ebedc0a6..12901725 100644 --- a/test/publish-files-definitions.test.mjs +++ b/test/publish-files-definitions.test.mjs @@ -26,9 +26,12 @@ const config = (files, server, token, cwd) => ({ beforeEach(async (t) => { const memSink = new Sink(); - const server = fastify({ logger: false }); - const service = new EikService({ customSink: memSink }); - server.register(service.api()); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); + const service = new EikService({ sink: memSink }); + await server.register(service.api()); const address = await server.listen({ host: "127.0.0.1", port: 0, @@ -236,9 +239,13 @@ test("when a recursive glob is specified", async (t) => { // @ts-expect-error const { files } = await cli.publish(config(pattern, address, token, cwd)); - t.equal(files[4].pathname, "/client.js", "client.js should be packaged at /"); t.equal( - files[11].pathname, + files.find((f) => f.pathname.endsWith("client.js")).pathname, + "/client.js", + "client.js should be packaged at /", + ); + t.equal( + files.find((f) => f.pathname.endsWith("checkboxes.svg")).pathname, "/icons/checkboxes.svg", "svgs should be packaged under /icons", ); @@ -252,7 +259,11 @@ test("when a non recursive glob is specified", async (t) => { const nested = files.filter((file) => file.pathname.includes("icons")); - t.equal(files[4].pathname, "/client.js", "client.js should be packaged at /"); + t.equal( + files.find((f) => f.pathname.endsWith("client.js")).pathname, + "/client.js", + "client.js should be packaged at /", + ); t.equal(nested.length, 0, "no nested files should be present"); }); diff --git a/test/publish.map.test.mjs b/test/publish.map.test.mjs index 2818b78f..db8c1a6c 100644 --- a/test/publish.map.test.mjs +++ b/test/publish.map.test.mjs @@ -15,9 +15,12 @@ const __dirname = dirname(__filename); beforeEach(async (t) => { const memSink = new Sink(); - const server = fastify({ logger: false }); - const service = new EikService({ customSink: memSink }); - server.register(service.api()); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); + const service = new EikService({ sink: memSink }); + await server.register(service.api()); const address = await server.listen({ host: "127.0.0.1", port: 0, diff --git a/test/publish.package.test.mjs b/test/publish.package.test.mjs index 91bdd974..8327a945 100644 --- a/test/publish.package.test.mjs +++ b/test/publish.package.test.mjs @@ -15,9 +15,12 @@ const __dirname = dirname(__filename); beforeEach(async (t) => { const memSink = new Sink(); - const server = fastify({ logger: false }); - const service = new EikService({ customSink: memSink }); - server.register(service.api()); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); + const service = new EikService({ sink: memSink }); + await server.register(service.api()); const address = await server.listen({ host: "127.0.0.1", port: 0, diff --git a/test/utils.test.mjs b/test/utils.test.mjs index 8b8d6e72..02cb9071 100644 --- a/test/utils.test.mjs +++ b/test/utils.test.mjs @@ -73,7 +73,10 @@ test("compare hashes - false", async (t) => { }); test("fetch latest version for a given published bundle", async (t) => { - const server = fastify(); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); server.get("/pkg/foo", async () => ({ versions: [ [1, { version: "1.3.2" }], @@ -93,7 +96,10 @@ test("fetch latest version for a given published bundle", async (t) => { }); test("fetch latest version, filtered by major, for a given published bundle", async (t) => { - const server = fastify(); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); server.get("/pkg/foo", async () => ({ versions: [ [1, { version: "1.3.2" }], @@ -113,7 +119,10 @@ test("fetch latest version, filtered by major, for a given published bundle", as }); test("fetch latest version for a given published bundle, non existant bundle on server", async (t) => { - const server = fastify(); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); const address = await server.listen({ host: "127.0.0.1", port: 0, @@ -133,7 +142,10 @@ test("fetch latest version for a given published bundle, non existant bundle on }); test("fetch latest version, filtered by major, for a given published bundle", async (t) => { - const server = fastify(); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); server.get("/pkg/foo", async () => ""); const address = await server.listen({ host: "127.0.0.1", @@ -154,7 +166,10 @@ test("fetch latest version, filtered by major, for a given published bundle", as }); test("fetch latest version, invalid versions returned by server", async (t) => { - const server = fastify(); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); server.get("/pkg/foo", async () => ({ versions: 1 })); const address = await server.listen({ host: "127.0.0.1", @@ -170,7 +185,10 @@ test("fetch latest version, invalid versions returned by server", async (t) => { }); test("fetch latest version, invalid versions keys returned by server", async (t) => { - const server = fastify(); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); server.get("/pkg/foo", async () => ({ versions: [ ["not a number", 1], @@ -191,7 +209,10 @@ test("fetch latest version, invalid versions keys returned by server", async (t) }); test("fetch latest version, no bundles yet published", async (t) => { - const server = fastify(); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); server.get("/pkg/foo", async () => ({ latest: {}, versions: [], @@ -209,7 +230,10 @@ test("fetch latest version, no bundles yet published", async (t) => { }); test("fetch remote hash for a given version", async (t) => { - const server = fastify(); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); server.get("/pkg/foo/1.0.0", async () => ({ integrity: "sha512-36Ug1lJ/p/H0n5+or1HDLrqLaI3nvB7j2f7PC9RIzWd3T5GE4CfOuClEZRiNsf/F4BjT5FnS9mz0EzeDHpu3uw==", diff --git a/test/version.test.mjs b/test/version.test.mjs index 1b078564..ac00b406 100644 --- a/test/version.test.mjs +++ b/test/version.test.mjs @@ -14,9 +14,12 @@ const __dirname = dirname(__filename); beforeEach(async (t) => { const memSink = new Sink(); - const server = fastify({ logger: false }); - const service = new EikService({ customSink: memSink }); - server.register(service.api()); + const server = fastify({ + ignoreTrailingSlash: true, + forceCloseConnections: true, + }); + const service = new EikService({ sink: memSink }); + await server.register(service.api()); const address = await server.listen({ host: "127.0.0.1", port: 0,