fix(deps): move file-type to deps (#6171)
This commit is contained in:
@@ -1,3 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* Ignores all ESM packages that make Jest mad.
|
||||||
|
*
|
||||||
|
* "Jest encountered an unexpected token"
|
||||||
|
*
|
||||||
|
* Direct packages:
|
||||||
|
* - file-type
|
||||||
|
*/
|
||||||
|
const esModules = [
|
||||||
|
// file-type and all dependencies: https://github.com/sindresorhus/file-type
|
||||||
|
'file-type',
|
||||||
|
'strtok3',
|
||||||
|
'readable-web-to-node-stream',
|
||||||
|
'token-types',
|
||||||
|
'peek-readable',
|
||||||
|
].join('|')
|
||||||
|
|
||||||
/** @type {import('jest').Config} */
|
/** @type {import('jest').Config} */
|
||||||
const baseJestConfig = {
|
const baseJestConfig = {
|
||||||
extensionsToTreatAsEsm: ['.ts', '.tsx'],
|
extensionsToTreatAsEsm: ['.ts', '.tsx'],
|
||||||
@@ -14,6 +31,10 @@ const baseJestConfig = {
|
|||||||
transform: {
|
transform: {
|
||||||
'^.+\\.(t|j)sx?$': ['@swc/jest'],
|
'^.+\\.(t|j)sx?$': ['@swc/jest'],
|
||||||
},
|
},
|
||||||
|
transformIgnorePatterns: [
|
||||||
|
`/node_modules/(?!.pnpm)(?!(${esModules})/)`,
|
||||||
|
`/node_modules/.pnpm/(?!(${esModules.replace(/\//g, '\\+')})@)`,
|
||||||
|
],
|
||||||
verbose: true,
|
verbose: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,8 +49,10 @@
|
|||||||
"@types/busboy": "^1.5.3",
|
"@types/busboy": "^1.5.3",
|
||||||
"busboy": "^1.6.0",
|
"busboy": "^1.6.0",
|
||||||
"deep-equal": "2.2.2",
|
"deep-equal": "2.2.2",
|
||||||
|
"file-type": "19.0.0",
|
||||||
"graphql-http": "^1.22.0",
|
"graphql-http": "^1.22.0",
|
||||||
"graphql-playground-html": "1.6.30",
|
"graphql-playground-html": "1.6.30",
|
||||||
|
"http-status": "1.6.2",
|
||||||
"path-to-regexp": "^6.2.1",
|
"path-to-regexp": "^6.2.1",
|
||||||
"qs": "6.11.2",
|
"qs": "6.11.2",
|
||||||
"react-diff-viewer-continued": "3.2.6",
|
"react-diff-viewer-continued": "3.2.6",
|
||||||
@@ -66,7 +68,6 @@
|
|||||||
"@types/ws": "^8.5.10",
|
"@types/ws": "^8.5.10",
|
||||||
"css-loader": "^6.10.0",
|
"css-loader": "^6.10.0",
|
||||||
"css-minimizer-webpack-plugin": "^6.0.0",
|
"css-minimizer-webpack-plugin": "^6.0.0",
|
||||||
"file-type": "16.5.4",
|
|
||||||
"mini-css-extract-plugin": "1.6.2",
|
"mini-css-extract-plugin": "1.6.2",
|
||||||
"payload": "workspace:*",
|
"payload": "workspace:*",
|
||||||
"postcss-loader": "^8.1.1",
|
"postcss-loader": "^8.1.1",
|
||||||
@@ -79,9 +80,7 @@
|
|||||||
"webpack-cli": "^5.1.4"
|
"webpack-cli": "^5.1.4"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"file-type": "16.5.4",
|
|
||||||
"graphql": "^16.8.1",
|
"graphql": "^16.8.1",
|
||||||
"http-status": "1.6.2",
|
|
||||||
"next": "^14.3.0-canary.7",
|
"next": "^14.3.0-canary.7",
|
||||||
"payload": "workspace:*"
|
"payload": "workspace:*"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { Collection, PayloadRequestWithData } from 'payload/types'
|
import type { Collection, PayloadRequestWithData } from 'payload/types'
|
||||||
|
|
||||||
import getFileType from 'file-type'
|
import { fileTypeFromFile } from 'file-type'
|
||||||
import fsPromises from 'fs/promises'
|
import fsPromises from 'fs/promises'
|
||||||
import httpStatus from 'http-status'
|
import httpStatus from 'http-status'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
@@ -58,7 +58,7 @@ export const getFile = async ({ collection, filename, req }: Args): Promise<Resp
|
|||||||
'Content-Length': stats.size + '',
|
'Content-Length': stats.size + '',
|
||||||
})
|
})
|
||||||
|
|
||||||
const fileTypeResult = (await getFileType.fromFile(filePath)) || getFileTypeFallback(filePath)
|
const fileTypeResult = (await fileTypeFromFile(filePath)) || getFileTypeFallback(filePath)
|
||||||
headers.set('Content-Type', fileTypeResult.mime)
|
headers.set('Content-Type', fileTypeResult.mime)
|
||||||
|
|
||||||
return new Response(data, {
|
return new Response(data, {
|
||||||
|
|||||||
69
pnpm-lock.yaml
generated
69
pnpm-lock.yaml
generated
@@ -170,7 +170,7 @@ importers:
|
|||||||
version: 9.1.8
|
version: 9.1.8
|
||||||
next:
|
next:
|
||||||
specifier: ^14.3.0-canary.7
|
specifier: ^14.3.0-canary.7
|
||||||
version: 14.3.0-canary.7(@babel/core@7.24.4)(@playwright/test@1.43.0)(react-dom@18.2.0)(react@18.2.0)(sass@1.74.1)
|
version: 14.3.0-canary.7(@babel/core@7.24.4)(@playwright/test@1.43.0)(react-dom@18.2.0)(react@18.2.0)
|
||||||
node-mocks-http:
|
node-mocks-http:
|
||||||
specifier: ^1.14.1
|
specifier: ^1.14.1
|
||||||
version: 1.14.1
|
version: 1.14.1
|
||||||
@@ -619,6 +619,9 @@ importers:
|
|||||||
deep-equal:
|
deep-equal:
|
||||||
specifier: 2.2.2
|
specifier: 2.2.2
|
||||||
version: 2.2.2
|
version: 2.2.2
|
||||||
|
file-type:
|
||||||
|
specifier: 19.0.0
|
||||||
|
version: 19.0.0
|
||||||
graphql:
|
graphql:
|
||||||
specifier: ^16.8.1
|
specifier: ^16.8.1
|
||||||
version: 16.8.1
|
version: 16.8.1
|
||||||
@@ -674,9 +677,6 @@ importers:
|
|||||||
css-minimizer-webpack-plugin:
|
css-minimizer-webpack-plugin:
|
||||||
specifier: ^6.0.0
|
specifier: ^6.0.0
|
||||||
version: 6.0.0(esbuild@0.19.12)(webpack@5.91.0)
|
version: 6.0.0(esbuild@0.19.12)(webpack@5.91.0)
|
||||||
file-type:
|
|
||||||
specifier: 16.5.4
|
|
||||||
version: 16.5.4
|
|
||||||
mini-css-extract-plugin:
|
mini-css-extract-plugin:
|
||||||
specifier: 1.6.2
|
specifier: 1.6.2
|
||||||
version: 1.6.2(webpack@5.91.0)
|
version: 1.6.2(webpack@5.91.0)
|
||||||
@@ -1485,7 +1485,7 @@ importers:
|
|||||||
version: 2.3.0
|
version: 2.3.0
|
||||||
next:
|
next:
|
||||||
specifier: ^14.3.0-canary.7
|
specifier: ^14.3.0-canary.7
|
||||||
version: 14.3.0-canary.7(@babel/core@7.24.4)(@playwright/test@1.43.0)(react-dom@18.2.0)(react@18.2.0)(sass@1.74.1)
|
version: 14.3.0-canary.7(@babel/core@7.24.4)(@playwright/test@1.43.0)(react-dom@18.2.0)(react@18.2.0)
|
||||||
object-to-formdata:
|
object-to-formdata:
|
||||||
specifier: 4.5.1
|
specifier: 4.5.1
|
||||||
version: 4.5.1
|
version: 4.5.1
|
||||||
@@ -9701,6 +9701,7 @@ packages:
|
|||||||
readable-web-to-node-stream: 3.0.2
|
readable-web-to-node-stream: 3.0.2
|
||||||
strtok3: 6.3.0
|
strtok3: 6.3.0
|
||||||
token-types: 4.2.1
|
token-types: 4.2.1
|
||||||
|
dev: false
|
||||||
|
|
||||||
/file-type@17.1.6:
|
/file-type@17.1.6:
|
||||||
resolution: {integrity: sha512-hlDw5Ev+9e883s0pwUsuuYNu4tD7GgpUnOvykjv1Gya0ZIjuKumthDRua90VUn6/nlRKAjcxLUnHNTIUWwWIiw==}
|
resolution: {integrity: sha512-hlDw5Ev+9e883s0pwUsuuYNu4tD7GgpUnOvykjv1Gya0ZIjuKumthDRua90VUn6/nlRKAjcxLUnHNTIUWwWIiw==}
|
||||||
@@ -9711,6 +9712,15 @@ packages:
|
|||||||
token-types: 5.0.1
|
token-types: 5.0.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/file-type@19.0.0:
|
||||||
|
resolution: {integrity: sha512-s7cxa7/leUWLiXO78DVVfBVse+milos9FitauDLG1pI7lNaJ2+5lzPnr2N24ym+84HVwJL6hVuGfgVE+ALvU8Q==}
|
||||||
|
engines: {node: '>=18'}
|
||||||
|
dependencies:
|
||||||
|
readable-web-to-node-stream: 3.0.2
|
||||||
|
strtok3: 7.0.0
|
||||||
|
token-types: 5.0.1
|
||||||
|
dev: false
|
||||||
|
|
||||||
/filename-reserved-regex@3.0.0:
|
/filename-reserved-regex@3.0.0:
|
||||||
resolution: {integrity: sha512-hn4cQfU6GOT/7cFHXBqeBg2TbrMBgdD0kcjLhvSQYYwm3s4B6cjvBfb7nBALJLAXqmU5xajSa7X2NnUud/VCdw==}
|
resolution: {integrity: sha512-hn4cQfU6GOT/7cFHXBqeBg2TbrMBgdD0kcjLhvSQYYwm3s4B6cjvBfb7nBALJLAXqmU5xajSa7X2NnUud/VCdw==}
|
||||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||||
@@ -12344,6 +12354,48 @@ packages:
|
|||||||
/next-tick@1.1.0:
|
/next-tick@1.1.0:
|
||||||
resolution: {integrity: sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==}
|
resolution: {integrity: sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==}
|
||||||
|
|
||||||
|
/next@14.3.0-canary.7(@babel/core@7.24.4)(@playwright/test@1.43.0)(react-dom@18.2.0)(react@18.2.0):
|
||||||
|
resolution: {integrity: sha512-loPrWTCvHvZgOy3rgL9+2WpxNDxlRNt462ihqm/DUuyK8LUZV1F4H920YTAu1wEiYC8RrpNUbpz8K7KRYAkQiA==}
|
||||||
|
engines: {node: '>=18.17.0'}
|
||||||
|
hasBin: true
|
||||||
|
peerDependencies:
|
||||||
|
'@opentelemetry/api': ^1.1.0
|
||||||
|
'@playwright/test': ^1.41.2
|
||||||
|
react: ^18.0.0
|
||||||
|
react-dom: ^18.0.0
|
||||||
|
sass: ^1.3.0
|
||||||
|
peerDependenciesMeta:
|
||||||
|
'@opentelemetry/api':
|
||||||
|
optional: true
|
||||||
|
'@playwright/test':
|
||||||
|
optional: true
|
||||||
|
sass:
|
||||||
|
optional: true
|
||||||
|
dependencies:
|
||||||
|
'@next/env': 14.3.0-canary.7
|
||||||
|
'@playwright/test': 1.43.0
|
||||||
|
'@swc/helpers': 0.5.5
|
||||||
|
busboy: 1.6.0
|
||||||
|
caniuse-lite: 1.0.30001607
|
||||||
|
graceful-fs: 4.2.11
|
||||||
|
postcss: 8.4.31
|
||||||
|
react: 18.2.0
|
||||||
|
react-dom: 18.2.0(react@18.2.0)
|
||||||
|
styled-jsx: 5.1.1(@babel/core@7.24.4)(react@18.2.0)
|
||||||
|
optionalDependencies:
|
||||||
|
'@next/swc-darwin-arm64': 14.3.0-canary.7
|
||||||
|
'@next/swc-darwin-x64': 14.3.0-canary.7
|
||||||
|
'@next/swc-linux-arm64-gnu': 14.3.0-canary.7
|
||||||
|
'@next/swc-linux-arm64-musl': 14.3.0-canary.7
|
||||||
|
'@next/swc-linux-x64-gnu': 14.3.0-canary.7
|
||||||
|
'@next/swc-linux-x64-musl': 14.3.0-canary.7
|
||||||
|
'@next/swc-win32-arm64-msvc': 14.3.0-canary.7
|
||||||
|
'@next/swc-win32-ia32-msvc': 14.3.0-canary.7
|
||||||
|
'@next/swc-win32-x64-msvc': 14.3.0-canary.7
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- '@babel/core'
|
||||||
|
- babel-plugin-macros
|
||||||
|
|
||||||
/next@14.3.0-canary.7(@babel/core@7.24.4)(@playwright/test@1.43.0)(react-dom@18.2.0)(react@18.2.0)(sass@1.74.1):
|
/next@14.3.0-canary.7(@babel/core@7.24.4)(@playwright/test@1.43.0)(react-dom@18.2.0)(react@18.2.0)(sass@1.74.1):
|
||||||
resolution: {integrity: sha512-loPrWTCvHvZgOy3rgL9+2WpxNDxlRNt462ihqm/DUuyK8LUZV1F4H920YTAu1wEiYC8RrpNUbpz8K7KRYAkQiA==}
|
resolution: {integrity: sha512-loPrWTCvHvZgOy3rgL9+2WpxNDxlRNt462ihqm/DUuyK8LUZV1F4H920YTAu1wEiYC8RrpNUbpz8K7KRYAkQiA==}
|
||||||
engines: {node: '>=18.17.0'}
|
engines: {node: '>=18.17.0'}
|
||||||
@@ -12386,6 +12438,7 @@ packages:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- '@babel/core'
|
- '@babel/core'
|
||||||
- babel-plugin-macros
|
- babel-plugin-macros
|
||||||
|
dev: false
|
||||||
|
|
||||||
/node-abi@3.57.0:
|
/node-abi@3.57.0:
|
||||||
resolution: {integrity: sha512-Dp+A9JWxRaKuHP35H77I4kCKesDy5HUDEmScia2FyncMTOXASMyg251F5PhFoDA5uqBrDDffiLpbqnrZmNXW+g==}
|
resolution: {integrity: sha512-Dp+A9JWxRaKuHP35H77I4kCKesDy5HUDEmScia2FyncMTOXASMyg251F5PhFoDA5uqBrDDffiLpbqnrZmNXW+g==}
|
||||||
@@ -12886,11 +12939,11 @@ packages:
|
|||||||
/peek-readable@4.1.0:
|
/peek-readable@4.1.0:
|
||||||
resolution: {integrity: sha512-ZI3LnwUv5nOGbQzD9c2iDG6toheuXSZP5esSHBjopsXH4dg19soufvpUGA3uohi5anFtGb2lhAVdHzH6R/Evvg==}
|
resolution: {integrity: sha512-ZI3LnwUv5nOGbQzD9c2iDG6toheuXSZP5esSHBjopsXH4dg19soufvpUGA3uohi5anFtGb2lhAVdHzH6R/Evvg==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/peek-readable@5.0.0:
|
/peek-readable@5.0.0:
|
||||||
resolution: {integrity: sha512-YtCKvLUOvwtMGmrniQPdO7MwPjgkFBtFIrmfSbYmYuq3tKDV/mcfAhBth1+C3ru7uXIZasc/pHnb+YDYNkkj4A==}
|
resolution: {integrity: sha512-YtCKvLUOvwtMGmrniQPdO7MwPjgkFBtFIrmfSbYmYuq3tKDV/mcfAhBth1+C3ru7uXIZasc/pHnb+YDYNkkj4A==}
|
||||||
engines: {node: '>=14.16'}
|
engines: {node: '>=14.16'}
|
||||||
dev: true
|
|
||||||
|
|
||||||
/pend@1.2.0:
|
/pend@1.2.0:
|
||||||
resolution: {integrity: sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==}
|
resolution: {integrity: sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==}
|
||||||
@@ -15211,6 +15264,7 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@tokenizer/token': 0.3.0
|
'@tokenizer/token': 0.3.0
|
||||||
peek-readable: 4.1.0
|
peek-readable: 4.1.0
|
||||||
|
dev: false
|
||||||
|
|
||||||
/strtok3@7.0.0:
|
/strtok3@7.0.0:
|
||||||
resolution: {integrity: sha512-pQ+V+nYQdC5H3Q7qBZAz/MO6lwGhoC2gOAjuouGf/VO0m7vQRh8QNMl2Uf6SwAtzZ9bOw3UIeBukEGNJl5dtXQ==}
|
resolution: {integrity: sha512-pQ+V+nYQdC5H3Q7qBZAz/MO6lwGhoC2gOAjuouGf/VO0m7vQRh8QNMl2Uf6SwAtzZ9bOw3UIeBukEGNJl5dtXQ==}
|
||||||
@@ -15218,7 +15272,6 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@tokenizer/token': 0.3.0
|
'@tokenizer/token': 0.3.0
|
||||||
peek-readable: 5.0.0
|
peek-readable: 5.0.0
|
||||||
dev: true
|
|
||||||
|
|
||||||
/stubs@3.0.0:
|
/stubs@3.0.0:
|
||||||
resolution: {integrity: sha512-PdHt7hHUJKxvTCgbKX9C1V/ftOcjJQgz8BZwNfV5c4B6dcGqlpelTbJ999jBGZ2jYiPAwcX5dP6oBwVlBlUbxw==}
|
resolution: {integrity: sha512-PdHt7hHUJKxvTCgbKX9C1V/ftOcjJQgz8BZwNfV5c4B6dcGqlpelTbJ999jBGZ2jYiPAwcX5dP6oBwVlBlUbxw==}
|
||||||
@@ -15562,6 +15615,7 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@tokenizer/token': 0.3.0
|
'@tokenizer/token': 0.3.0
|
||||||
ieee754: 1.2.1
|
ieee754: 1.2.1
|
||||||
|
dev: false
|
||||||
|
|
||||||
/token-types@5.0.1:
|
/token-types@5.0.1:
|
||||||
resolution: {integrity: sha512-Y2fmSnZjQdDb9W4w4r1tswlMHylzWIeOKpx0aZH9BgGtACHhrk3OkT52AzwcuqTRBZtvvnTjDBh8eynMulu8Vg==}
|
resolution: {integrity: sha512-Y2fmSnZjQdDb9W4w4r1tswlMHylzWIeOKpx0aZH9BgGtACHhrk3OkT52AzwcuqTRBZtvvnTjDBh8eynMulu8Vg==}
|
||||||
@@ -15569,7 +15623,6 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@tokenizer/token': 0.3.0
|
'@tokenizer/token': 0.3.0
|
||||||
ieee754: 1.2.1
|
ieee754: 1.2.1
|
||||||
dev: true
|
|
||||||
|
|
||||||
/totalist@3.0.1:
|
/totalist@3.0.1:
|
||||||
resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==}
|
resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==}
|
||||||
|
|||||||
Reference in New Issue
Block a user