Update frontend dependencies to latest, bump pnpm to 10, clear all npm audit alerts
pnpm 8.15.9 -> 10.10.0 (packageManager + lockfile regenerated to v9). Frontend CI (ci-frontend.yml, ci-frontend-api.yml, release.yml) and the production Dockerfile bumped from node 16 + pnpm 8 to node 20 + pnpm 10 (pnpm 10 requires node 18+). pnpm audit: no known vulnerabilities (was 63 alerts). packages/api: bumped to latest including the major test stack - vitest 4, jsdom 29, @vitest/coverage-v8 4, @typescript-eslint 8.62, typescript 5.9, prettier 3.9, @types/node 26, and msw 1 -> 2. Migrated tests/test-utils.ts to the msw 2 http/HttpResponse API (capturing a compatible request shape) and made test base URLs absolute so node 20's native fetch is intercepted; added the jsdom base URL. type-check:api, lint:api and coverage:api (45 tests) all pass. apps/remark42: safe in-major bumps (webpack 5.108, postcss, mini-css-extract, html-webpack-plugin, ts-loader, webpack-dev-server 5.2.5, core-js, clsx 2, lodash-es 4.18, dotenv 17, @types/*). Transitive vulns patched via pnpm.overrides. type-check, lint, build, jest coverage (299 tests) and translations all pass. pnpm 10's stricter layout required a few pins to keep the app's preact-compat setup compiling: preact 10.6.2 (override), react-intl 6.0.5 and @testing-library/preact 3.2.2 (newer types break the build), tsconfig paths for preact, @types/minimatch 5.1.2 (6.x is an empty stub) and cheerio 1.0.0-rc.12 (1.2 is ESM and breaks jest 28). Held: react/react-dom (preact compat alias), babel 7, eslint 8, stylelint 14, jest 28, typescript 4.7 (app), redux/react-redux - majors that change the bundle or need a config migration. Build output verified against a clean master build: apps/remark42 output is functionally identical (the only diffs are webpack module-id numbering and css-module class tokens from the webpack/css-loader bump; all HTML, CSS values and translations byte-identical).
This commit is contained in:
@@ -29,24 +29,23 @@
|
||||
"type-check": "tsc --noEmit",
|
||||
"lint-staged:lint": "eslint --fix --ext .cjs,.mjs,.ts"
|
||||
},
|
||||
"packageManager": "pnpm@8.15.9",
|
||||
"packageManager": "pnpm@10.10.0",
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.19.64",
|
||||
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
||||
"@typescript-eslint/parser": "^8.13.0",
|
||||
"@vitest/coverage-v8": "^2.1.4",
|
||||
"@types/node": "^26.0.1",
|
||||
"@typescript-eslint/eslint-plugin": "^8.62.1",
|
||||
"@typescript-eslint/parser": "^8.62.1",
|
||||
"@vitest/coverage-v8": "^4.1.9",
|
||||
"eslint": "^8.57.1",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.2.1",
|
||||
"jsdom": "^25.0.1",
|
||||
"msw": "^1.3.5",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-prettier": "^5.5.6",
|
||||
"jsdom": "^29.1.1",
|
||||
"msw": "^2.14.6",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^3.3.3",
|
||||
"ts-node": "^10.9.1",
|
||||
"tslib": "^2.4.0",
|
||||
"typescript": "^4.9.5",
|
||||
"vitest": "^2.1.4",
|
||||
"whatwg-fetch": "^3.6.2"
|
||||
"prettier": "^3.9.4",
|
||||
"ts-node": "^10.9.2",
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.9.3",
|
||||
"vitest": "^4.1.9"
|
||||
},
|
||||
"type": "module",
|
||||
"files": [
|
||||
|
||||
@@ -8,7 +8,7 @@ interface Context {
|
||||
|
||||
describe<Context>('Admin Client', (adminClient) => {
|
||||
beforeEach<Context>((ctx) => {
|
||||
ctx.client = createAdminClient({ siteId: 'mysite', baseUrl: '/remark42' })
|
||||
ctx.client = createAdminClient({ siteId: 'mysite', baseUrl: 'http://localhost/remark42' })
|
||||
})
|
||||
|
||||
adminClient('should return list of blocked users', async ({ client }) => {
|
||||
|
||||
@@ -8,7 +8,7 @@ interface Content {
|
||||
|
||||
describe<Content>('Auth Client', (authClient) => {
|
||||
beforeEach<Content>((ctx) => {
|
||||
ctx.client = createAuthClient({ siteId: 'mysite', baseUrl: '/remark42' })
|
||||
ctx.client = createAuthClient({ siteId: 'mysite', baseUrl: 'http://localhost/remark42' })
|
||||
})
|
||||
|
||||
authClient('should authorize as anonymouse', async ({ client }) => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { createClient } from '../..'
|
||||
|
||||
describe('Client', () => {
|
||||
it('should create a client', () => {
|
||||
const params = { siteId: 'mysite', baseUrl: '/remark42' }
|
||||
const params = { siteId: 'mysite', baseUrl: 'http://localhost/remark42' }
|
||||
const client = createClient(params)
|
||||
|
||||
expect(client).toBeDefined()
|
||||
|
||||
@@ -8,7 +8,7 @@ interface Context {
|
||||
|
||||
describe<Context>('Public Client', (publicClient) => {
|
||||
beforeEach<Context>((ctx) => {
|
||||
ctx.client = createPublicClient({ siteId: 'mysite', baseUrl: '/remark42' })
|
||||
ctx.client = createPublicClient({ siteId: 'mysite', baseUrl: 'http://localhost/remark42' })
|
||||
})
|
||||
|
||||
publicClient('getConfig: should return config', async ({ client }) => {
|
||||
|
||||
@@ -9,7 +9,7 @@ interface Context {
|
||||
|
||||
describe<Context>('Fetcher', (fetcher) => {
|
||||
beforeEach<Context>((ctx) => {
|
||||
ctx.client = createFetcher('remark42', '')
|
||||
ctx.client = createFetcher('remark42', 'http://localhost')
|
||||
})
|
||||
|
||||
fetcher('get', async ({ client }) => {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'whatwg-fetch'
|
||||
import { afterAll, afterEach, beforeAll } from 'vitest'
|
||||
import { server } from './test-utils'
|
||||
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
import { rest, RestRequest } from 'msw'
|
||||
import { http, HttpResponse } from 'msw'
|
||||
import { setupServer } from 'msw/node'
|
||||
|
||||
export const server = setupServer()
|
||||
|
||||
interface CapturedRequest {
|
||||
url: URL
|
||||
method: string
|
||||
headers: Headers
|
||||
json: () => Promise<unknown>
|
||||
text: () => Promise<string>
|
||||
}
|
||||
|
||||
interface RequestRef {
|
||||
req: RestRequest
|
||||
req: CapturedRequest
|
||||
}
|
||||
|
||||
export function mockEndpoint(
|
||||
@@ -20,15 +28,26 @@ export function mockEndpoint(
|
||||
const result = { req: {} } as RequestRef
|
||||
|
||||
server.use(
|
||||
rest[method](url, (req, res, ctx) => {
|
||||
const transformers = [ctx.status(status), ctx.json(body)]
|
||||
|
||||
if (headers) {
|
||||
transformers.push(ctx.set(headers))
|
||||
http[method](url, ({ request }) => {
|
||||
const captured = request.clone()
|
||||
result.req = {
|
||||
url: new URL(request.url),
|
||||
method: request.method,
|
||||
headers: request.headers,
|
||||
json: () => captured.clone().json(),
|
||||
text: () => captured.clone().text(),
|
||||
}
|
||||
|
||||
result.req = req
|
||||
return res(...transformers)
|
||||
const responseHeaders = new Headers()
|
||||
if (headers) {
|
||||
for (const [key, value] of Object.entries(headers)) {
|
||||
responseHeaders.set(key, Array.isArray(value) ? value.join(', ') : value)
|
||||
}
|
||||
}
|
||||
|
||||
return body === undefined
|
||||
? new HttpResponse(null, { status, headers: responseHeaders })
|
||||
: HttpResponse.json(body, { status, headers: responseHeaders })
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
@@ -3,6 +3,11 @@ import { defineConfig } from 'vitest/config'
|
||||
export default defineConfig({
|
||||
test: {
|
||||
environment: 'jsdom',
|
||||
environmentOptions: {
|
||||
jsdom: {
|
||||
url: 'http://localhost',
|
||||
},
|
||||
},
|
||||
setupFiles: ['./tests/setup.ts'],
|
||||
include: ['tests/**/*.test.ts'],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user