fix: nitro auto imporat in vitest

This commit is contained in:
Ou 2024-10-09 02:54:11 +08:00
parent 1357d04b90
commit ae81649d29
6 changed files with 287 additions and 41 deletions

137
auto-imports.d.ts vendored Normal file
View File

@ -0,0 +1,137 @@
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
// Generated by unplugin-auto-import
// biome-ignore lint: disable
export {}
declare global {
const $fetch: typeof import('ofetch')['$fetch']
const afterAll: typeof import('vitest')['afterAll']
const afterEach: typeof import('vitest')['afterEach']
const appendCorsHeaders: typeof import('h3')['appendCorsHeaders']
const appendCorsPreflightHeaders: typeof import('h3')['appendCorsPreflightHeaders']
const appendHeader: typeof import('h3')['appendHeader']
const appendHeaders: typeof import('h3')['appendHeaders']
const appendResponseHeader: typeof import('h3')['appendResponseHeader']
const appendResponseHeaders: typeof import('h3')['appendResponseHeaders']
const assert: typeof import('vitest')['assert']
const assertMethod: typeof import('h3')['assertMethod']
const beforeAll: typeof import('vitest')['beforeAll']
const beforeEach: typeof import('vitest')['beforeEach']
const callNodeListener: typeof import('h3')['callNodeListener']
const chai: typeof import('vitest')['chai']
const clearResponseHeaders: typeof import('h3')['clearResponseHeaders']
const clearSession: typeof import('h3')['clearSession']
const createApp: typeof import('h3')['createApp']
const createAppEventHandler: typeof import('h3')['createAppEventHandler']
const createError: typeof import('h3')['createError']
const createEvent: typeof import('h3')['createEvent']
const createEventStream: typeof import('h3')['createEventStream']
const createRouter: typeof import('h3')['createRouter']
const day: typeof import('./server/utils/date')['day']
const defaultContentType: typeof import('h3')['defaultContentType']
const defineEventHandler: typeof import('h3')['defineEventHandler']
const defineFallbackSource: typeof import('./server/utils/source')['defineFallbackSource']
const defineLazyEventHandler: typeof import('h3')['defineLazyEventHandler']
const defineNodeListener: typeof import('h3')['defineNodeListener']
const defineNodeMiddleware: typeof import('h3')['defineNodeMiddleware']
const defineRSSHubSource: typeof import('./server/utils/source')['defineRSSHubSource']
const defineRSSSource: typeof import('./server/utils/source')['defineRSSSource']
const defineRequestMiddleware: typeof import('h3')['defineRequestMiddleware']
const defineResponseMiddleware: typeof import('h3')['defineResponseMiddleware']
const defineSource: typeof import('./server/utils/source')['defineSource']
const defineWebSocket: typeof import('h3')['defineWebSocket']
const defineWebSocketHandler: typeof import('h3')['defineWebSocketHandler']
const deleteCookie: typeof import('h3')['deleteCookie']
const describe: typeof import('vitest')['describe']
const dynamicEventHandler: typeof import('h3')['dynamicEventHandler']
const eventHandler: typeof import('h3')['eventHandler']
const expect: typeof import('vitest')['expect']
const fetchWithEvent: typeof import('h3')['fetchWithEvent']
const fromNodeMiddleware: typeof import('h3')['fromNodeMiddleware']
const fromPlainHandler: typeof import('h3')['fromPlainHandler']
const fromWebHandler: typeof import('h3')['fromWebHandler']
const getCookie: typeof import('h3')['getCookie']
const getHeader: typeof import('h3')['getHeader']
const getHeaders: typeof import('h3')['getHeaders']
const getMethod: typeof import('h3')['getMethod']
const getProxyRequestHeaders: typeof import('h3')['getProxyRequestHeaders']
const getQuery: typeof import('h3')['getQuery']
const getRequestFingerprint: typeof import('h3')['getRequestFingerprint']
const getRequestHeader: typeof import('h3')['getRequestHeader']
const getRequestHeaders: typeof import('h3')['getRequestHeaders']
const getRequestHost: typeof import('h3')['getRequestHost']
const getRequestIP: typeof import('h3')['getRequestIP']
const getRequestPath: typeof import('h3')['getRequestPath']
const getRequestProtocol: typeof import('h3')['getRequestProtocol']
const getRequestURL: typeof import('h3')['getRequestURL']
const getRequestWebStream: typeof import('h3')['getRequestWebStream']
const getResponseHeader: typeof import('h3')['getResponseHeader']
const getResponseHeaders: typeof import('h3')['getResponseHeaders']
const getResponseStatus: typeof import('h3')['getResponseStatus']
const getResponseStatusText: typeof import('h3')['getResponseStatusText']
const getRouterParam: typeof import('h3')['getRouterParam']
const getRouterParams: typeof import('h3')['getRouterParams']
const getSession: typeof import('h3')['getSession']
const getValidatedQuery: typeof import('h3')['getValidatedQuery']
const getValidatedRouterParams: typeof import('h3')['getValidatedRouterParams']
const handleCacheHeaders: typeof import('h3')['handleCacheHeaders']
const handleCors: typeof import('h3')['handleCors']
const isCorsOriginAllowed: typeof import('h3')['isCorsOriginAllowed']
const isError: typeof import('h3')['isError']
const isEvent: typeof import('h3')['isEvent']
const isEventHandler: typeof import('h3')['isEventHandler']
const isMethod: typeof import('h3')['isMethod']
const isPreflightRequest: typeof import('h3')['isPreflightRequest']
const isStream: typeof import('h3')['isStream']
const isWebResponse: typeof import('h3')['isWebResponse']
const it: typeof import('vitest')['it']
const lazyEventHandler: typeof import('h3')['lazyEventHandler']
const logger: typeof import('./server/utils/logger')['logger']
const ofetch: typeof import('ofetch')['ofetch']
const parseCookies: typeof import('h3')['parseCookies']
const promisifyNodeListener: typeof import('h3')['promisifyNodeListener']
const proxyRequest: typeof import('h3')['proxyRequest']
const readBody: typeof import('h3')['readBody']
const readFormData: typeof import('h3')['readFormData']
const readMultipartFormData: typeof import('h3')['readMultipartFormData']
const readRawBody: typeof import('h3')['readRawBody']
const readValidatedBody: typeof import('h3')['readValidatedBody']
const removeResponseHeader: typeof import('h3')['removeResponseHeader']
const rss2json: typeof import('./server/utils/rss2json')['rss2json']
const sanitizeStatusCode: typeof import('h3')['sanitizeStatusCode']
const sanitizeStatusMessage: typeof import('h3')['sanitizeStatusMessage']
const sealSession: typeof import('h3')['sealSession']
const send: typeof import('h3')['send']
const sendError: typeof import('h3')['sendError']
const sendIterable: typeof import('h3')['sendIterable']
const sendNoContent: typeof import('h3')['sendNoContent']
const sendProxy: typeof import('h3')['sendProxy']
const sendRedirect: typeof import('h3')['sendRedirect']
const sendStream: typeof import('h3')['sendStream']
const sendWebResponse: typeof import('h3')['sendWebResponse']
const serveStatic: typeof import('h3')['serveStatic']
const setCookie: typeof import('h3')['setCookie']
const setHeader: typeof import('h3')['setHeader']
const setHeaders: typeof import('h3')['setHeaders']
const setResponseHeader: typeof import('h3')['setResponseHeader']
const setResponseHeaders: typeof import('h3')['setResponseHeaders']
const setResponseStatus: typeof import('h3')['setResponseStatus']
const splitCookiesString: typeof import('h3')['splitCookiesString']
const suite: typeof import('vitest')['suite']
const test: typeof import('vitest')['test']
const toEventHandler: typeof import('h3')['toEventHandler']
const toNodeListener: typeof import('h3')['toNodeListener']
const toPlainHandler: typeof import('h3')['toPlainHandler']
const toWebHandler: typeof import('h3')['toWebHandler']
const toWebRequest: typeof import('h3')['toWebRequest']
const tranformToUTC: typeof import('./server/utils/date')['tranformToUTC']
const unsealSession: typeof import('h3')['unsealSession']
const updateSession: typeof import('h3')['updateSession']
const useBase: typeof import('h3')['useBase']
const useSession: typeof import('h3')['useSession']
const vi: typeof import('vitest')['vi']
const vitest: typeof import('vitest')['vitest']
const writeEarlyHints: typeof import('h3')['writeEarlyHints']
}

View File

@ -14,7 +14,7 @@
"deploy": "CF_PAGES=1 pnpm run build && wrangler pages deploy", "deploy": "CF_PAGES=1 pnpm run build && wrangler pages deploy",
"release": "bumpp", "release": "bumpp",
"prepare": "simple-git-hooks", "prepare": "simple-git-hooks",
"test": "vitest" "test": "vitest -c vitest.config.ts"
}, },
"dependencies": { "dependencies": {
"@dnd-kit/core": "^6.1.0", "@dnd-kit/core": "^6.1.0",
@ -32,9 +32,11 @@
"db0": "npm:@ourongxing/db0@latest", "db0": "npm:@ourongxing/db0@latest",
"fast-xml-parser": "^4.5.0", "fast-xml-parser": "^4.5.0",
"favicons-scraper": "^1.3.2", "favicons-scraper": "^1.3.2",
"h3": "^1.13.0",
"iconv-lite": "^0.6.3", "iconv-lite": "^0.6.3",
"jotai": "^2.10.0", "jotai": "^2.10.0",
"libsql": "^0.4.5", "libsql": "^0.4.5",
"md5": "^2.3.0",
"ofetch": "^1.4.0", "ofetch": "^1.4.0",
"overlayscrollbars": "^2.10.0", "overlayscrollbars": "^2.10.0",
"overlayscrollbars-react": "^0.5.6", "overlayscrollbars-react": "^0.5.6",
@ -50,6 +52,7 @@
"@ourongxing/eslint-config": "3.2.3-beta.4", "@ourongxing/eslint-config": "3.2.3-beta.4",
"@ourongxing/tsconfig": "^0.0.4", "@ourongxing/tsconfig": "^0.0.4",
"@tanstack/router-plugin": "^1.58.10", "@tanstack/router-plugin": "^1.58.10",
"@types/md5": "^2.3.5",
"@types/react": "^18.3.9", "@types/react": "^18.3.9",
"@types/react-dom": "^18.3.0", "@types/react-dom": "^18.3.0",
"@vitejs/plugin-react-swc": "^3.7.0", "@vitejs/plugin-react-swc": "^3.7.0",
@ -58,12 +61,14 @@
"eslint-plugin-react-hooks": "^5.1.0-rc-778e1ed2-20240926", "eslint-plugin-react-hooks": "^5.1.0-rc-778e1ed2-20240926",
"eslint-plugin-react-refresh": "^0.4.12", "eslint-plugin-react-refresh": "^0.4.12",
"lint-staged": "^15.2.10", "lint-staged": "^15.2.10",
"mlly": "^1.7.2",
"nitropack": "^2.9.7", "nitropack": "^2.9.7",
"simple-git-hooks": "^2.11.1", "simple-git-hooks": "^2.11.1",
"tsx": "^4.19.1", "tsx": "^4.19.1",
"typescript": "^5.6.2", "typescript": "^5.6.2",
"typescript-eslint": "^8.7.0", "typescript-eslint": "^8.7.0",
"unocss": "^0.62.4", "unocss": "^0.62.4",
"unplugin-auto-import": "^0.18.3",
"vite": "^5.4.8", "vite": "^5.4.8",
"vite-plugin-with-nitro": "0.0.0-beta.4", "vite-plugin-with-nitro": "0.0.0-beta.4",
"vite-tsconfig-paths": "^5.0.1", "vite-tsconfig-paths": "^5.0.1",

106
pnpm-lock.yaml generated
View File

@ -56,6 +56,9 @@ importers:
favicons-scraper: favicons-scraper:
specifier: ^1.3.2 specifier: ^1.3.2
version: 1.3.2 version: 1.3.2
h3:
specifier: ^1.13.0
version: 1.13.0
iconv-lite: iconv-lite:
specifier: ^0.6.3 specifier: ^0.6.3
version: 0.6.3 version: 0.6.3
@ -65,6 +68,9 @@ importers:
libsql: libsql:
specifier: ^0.4.5 specifier: ^0.4.5
version: 0.4.5 version: 0.4.5
md5:
specifier: ^2.3.0
version: 2.3.0
ofetch: ofetch:
specifier: ^1.4.0 specifier: ^1.4.0
version: 1.4.0 version: 1.4.0
@ -105,6 +111,9 @@ importers:
'@tanstack/router-plugin': '@tanstack/router-plugin':
specifier: ^1.58.10 specifier: ^1.58.10
version: 1.58.10(vite@5.4.8(@types/node@22.6.1)(terser@5.33.0)) version: 1.58.10(vite@5.4.8(@types/node@22.6.1)(terser@5.33.0))
'@types/md5':
specifier: ^2.3.5
version: 2.3.5
'@types/react': '@types/react':
specifier: ^18.3.9 specifier: ^18.3.9
version: 18.3.9 version: 18.3.9
@ -129,6 +138,9 @@ importers:
lint-staged: lint-staged:
specifier: ^15.2.10 specifier: ^15.2.10
version: 15.2.10 version: 15.2.10
mlly:
specifier: ^1.7.2
version: 1.7.2
nitropack: nitropack:
specifier: ^2.9.7 specifier: ^2.9.7
version: 2.9.7(encoding@0.1.13)(libsql@0.4.5)(magicast@0.3.5) version: 2.9.7(encoding@0.1.13)(libsql@0.4.5)(magicast@0.3.5)
@ -147,6 +159,9 @@ importers:
unocss: unocss:
specifier: ^0.62.4 specifier: ^0.62.4
version: 0.62.4(postcss@8.4.47)(rollup@4.22.4)(vite@5.4.8(@types/node@22.6.1)(terser@5.33.0)) version: 0.62.4(postcss@8.4.47)(rollup@4.22.4)(vite@5.4.8(@types/node@22.6.1)(terser@5.33.0))
unplugin-auto-import:
specifier: ^0.18.3
version: 0.18.3(rollup@4.22.4)
vite: vite:
specifier: ^5.4.8 specifier: ^5.4.8
version: 5.4.8(@types/node@22.6.1)(terser@5.33.0) version: 5.4.8(@types/node@22.6.1)(terser@5.33.0)
@ -1757,6 +1772,9 @@ packages:
'@types/json-schema@7.0.15': '@types/json-schema@7.0.15':
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
'@types/md5@2.3.5':
resolution: {integrity: sha512-/i42wjYNgE6wf0j2bcTX6kuowmdL/6PE4IVitMpm2eYKBUuYCprdcWVK+xEF0gcV6ufMCRhtxmReGfc6hIK7Jw==}
'@types/mdast@3.0.15': '@types/mdast@3.0.15':
resolution: {integrity: sha512-LnwD+mUEfxWMa1QpDraczIn6k0Ee3SMicuYSSzS6ZYl2gKS09EClnJYGd8Du6rfc5r/GZEk5o1mRb8TaTj03sQ==} resolution: {integrity: sha512-LnwD+mUEfxWMa1QpDraczIn6k0Ee3SMicuYSSzS6ZYl2gKS09EClnJYGd8Du6rfc5r/GZEk5o1mRb8TaTj03sQ==}
@ -2219,6 +2237,9 @@ packages:
character-reference-invalid@1.1.4: character-reference-invalid@1.1.4:
resolution: {integrity: sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==} resolution: {integrity: sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==}
charenc@0.0.2:
resolution: {integrity: sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==}
check-error@2.1.1: check-error@2.1.1:
resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==} resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==}
engines: {node: '>= 16'} engines: {node: '>= 16'}
@ -2368,6 +2389,9 @@ packages:
uWebSockets.js: uWebSockets.js:
optional: true optional: true
crypt@0.0.2:
resolution: {integrity: sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==}
css-in-js-utils@3.1.0: css-in-js-utils@3.1.0:
resolution: {integrity: sha512-fJAcud6B3rRu+KHYk+Bwf+WFL2MDCJJ1XG9x137tJQ0xYxor7XziQtuGFbWNdqrvF4Tk26O3H73nfVqXt/fW1A==} resolution: {integrity: sha512-fJAcud6B3rRu+KHYk+Bwf+WFL2MDCJJ1XG9x137tJQ0xYxor7XziQtuGFbWNdqrvF4Tk26O3H73nfVqXt/fW1A==}
@ -3096,8 +3120,8 @@ packages:
resolution: {integrity: sha512-O1Ld7Dr+nqPnmGpdhzLmMTQ4vAsD+rHwMm1NLUmoUFFymBOMKxCCrtDxqdBRYXdeEPEi3SyoR4TizJLQrnKBNA==} resolution: {integrity: sha512-O1Ld7Dr+nqPnmGpdhzLmMTQ4vAsD+rHwMm1NLUmoUFFymBOMKxCCrtDxqdBRYXdeEPEi3SyoR4TizJLQrnKBNA==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
h3@1.12.0: h3@1.13.0:
resolution: {integrity: sha512-Zi/CcNeWBXDrFNlV0hUBJQR9F7a96RjMeAZweW/ZWkR9fuXrMcvKnSA63f/zZ9l0GgQOZDVHGvXivNN9PWOwhA==} resolution: {integrity: sha512-vFEAu/yf8UMUcB4s43OaDaigcqpQd14yanmOsn+NcRX3/guSKncyE2rOYhq8RIchgJrPSs/QiIddnTTR1ddiAg==}
has-flag@3.0.0: has-flag@3.0.0:
resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==}
@ -3201,6 +3225,9 @@ packages:
resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==}
engines: {node: '>=8'} engines: {node: '>=8'}
is-buffer@1.1.6:
resolution: {integrity: sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==}
is-builtin-module@3.2.1: is-builtin-module@3.2.1:
resolution: {integrity: sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==} resolution: {integrity: sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==}
engines: {node: '>=6'} engines: {node: '>=6'}
@ -3488,6 +3515,9 @@ packages:
resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==} resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==}
engines: {node: '>=8'} engines: {node: '>=8'}
md5@2.3.0:
resolution: {integrity: sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==}
mdast-util-from-markdown@0.8.5: mdast-util-from-markdown@0.8.5:
resolution: {integrity: sha512-2hkTXtYYnr+NubD/g6KGBS/0mFmBcifAsI0yIWRiRo0PjVs6SSOSOdtzbp6kSGnShDN6G5aWZpKQ2lWRy27mWQ==} resolution: {integrity: sha512-2hkTXtYYnr+NubD/g6KGBS/0mFmBcifAsI0yIWRiRo0PjVs6SSOSOdtzbp6kSGnShDN6G5aWZpKQ2lWRy27mWQ==}
@ -3582,8 +3612,8 @@ packages:
engines: {node: '>=10'} engines: {node: '>=10'}
hasBin: true hasBin: true
mlly@1.7.1: mlly@1.7.2:
resolution: {integrity: sha512-rrVRZRELyQzrIUAVMHxP97kv+G786pHmOKzuFII8zDYahFBS7qnHh2AlYSl1GAHhaMPCz6/oHjVMcfFYgFYHgA==} resolution: {integrity: sha512-tN3dvVHYVz4DhSXinXIk7u9syPYaJvio118uomkovAtWBT+RdbP6Lfh/5Lvo519YMmwBafwlh20IPTXIStscpA==}
mri@1.2.0: mri@1.2.0:
resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==}
@ -4549,6 +4579,18 @@ packages:
vite: vite:
optional: true optional: true
unplugin-auto-import@0.18.3:
resolution: {integrity: sha512-q3FUtGQjYA2e+kb1WumyiQMjHM27MrTQ05QfVwtLRVhyYe+KF6TblBYaEX9L6Z0EibsqaXAiW+RFfkcQpfaXzg==}
engines: {node: '>=14'}
peerDependencies:
'@nuxt/kit': ^3.2.2
'@vueuse/core': '*'
peerDependenciesMeta:
'@nuxt/kit':
optional: true
'@vueuse/core':
optional: true
unplugin@1.14.1: unplugin@1.14.1:
resolution: {integrity: sha512-lBlHbfSFPToDYp9pjXlUEFVxYLaue9f9T1HC+4OHlmj+HnMDdz9oZY+erXfoCe/5V/7gKUSY2jpXPb9S7f0f/w==} resolution: {integrity: sha512-lBlHbfSFPToDYp9pjXlUEFVxYLaue9f9T1HC+4OHlmj+HnMDdz9oZY+erXfoCe/5V/7gKUSY2jpXPb9S7f0f/w==}
engines: {node: '>=14.0.0'} engines: {node: '>=14.0.0'}
@ -5588,7 +5630,7 @@ snapshots:
debug: 4.3.7 debug: 4.3.7
kolorist: 1.8.0 kolorist: 1.8.0
local-pkg: 0.5.0 local-pkg: 0.5.0
mlly: 1.7.1 mlly: 1.7.2
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
@ -6135,6 +6177,8 @@ snapshots:
'@types/json-schema@7.0.15': {} '@types/json-schema@7.0.15': {}
'@types/md5@2.3.5': {}
'@types/mdast@3.0.15': '@types/mdast@3.0.15':
dependencies: dependencies:
'@types/unist': 2.0.11 '@types/unist': 2.0.11
@ -6689,7 +6733,7 @@ snapshots:
dotenv: 16.4.5 dotenv: 16.4.5
giget: 1.2.3 giget: 1.2.3
jiti: 1.21.6 jiti: 1.21.6
mlly: 1.7.1 mlly: 1.7.2
ohash: 1.1.4 ohash: 1.1.4
pathe: 1.1.2 pathe: 1.1.2
perfect-debounce: 1.0.0 perfect-debounce: 1.0.0
@ -6740,6 +6784,8 @@ snapshots:
character-reference-invalid@1.1.4: {} character-reference-invalid@1.1.4: {}
charenc@0.0.2: {}
check-error@2.1.1: {} check-error@2.1.1: {}
cheerio-select@2.1.0: cheerio-select@2.1.0:
@ -6887,6 +6933,8 @@ snapshots:
crossws@0.2.4: {} crossws@0.2.4: {}
crypt@0.0.2: {}
css-in-js-utils@3.1.0: css-in-js-utils@3.1.0:
dependencies: dependencies:
hyphenate-style-name: 1.1.0 hyphenate-style-name: 1.1.0
@ -7823,7 +7871,7 @@ snapshots:
dependencies: dependencies:
duplexer: 0.1.2 duplexer: 0.1.2
h3@1.12.0: h3@1.13.0:
dependencies: dependencies:
cookie-es: 1.2.2 cookie-es: 1.2.2
crossws: 0.2.4 crossws: 0.2.4
@ -7951,6 +7999,8 @@ snapshots:
dependencies: dependencies:
binary-extensions: 2.3.0 binary-extensions: 2.3.0
is-buffer@1.1.6: {}
is-builtin-module@3.2.1: is-builtin-module@3.2.1:
dependencies: dependencies:
builtin-modules: 3.3.0 builtin-modules: 3.3.0
@ -8151,10 +8201,10 @@ snapshots:
crossws: 0.2.4 crossws: 0.2.4
defu: 6.1.4 defu: 6.1.4
get-port-please: 3.1.2 get-port-please: 3.1.2
h3: 1.12.0 h3: 1.13.0
http-shutdown: 1.2.2 http-shutdown: 1.2.2
jiti: 1.21.6 jiti: 1.21.6
mlly: 1.7.1 mlly: 1.7.2
node-forge: 1.3.1 node-forge: 1.3.1
pathe: 1.1.2 pathe: 1.1.2
std-env: 3.7.0 std-env: 3.7.0
@ -8177,7 +8227,7 @@ snapshots:
local-pkg@0.5.0: local-pkg@0.5.0:
dependencies: dependencies:
mlly: 1.7.1 mlly: 1.7.2
pkg-types: 1.2.0 pkg-types: 1.2.0
locate-path@5.0.0: locate-path@5.0.0:
@ -8237,6 +8287,12 @@ snapshots:
dependencies: dependencies:
semver: 6.3.1 semver: 6.3.1
md5@2.3.0:
dependencies:
charenc: 0.0.2
crypt: 0.0.2
is-buffer: 1.1.6
mdast-util-from-markdown@0.8.5: mdast-util-from-markdown@0.8.5:
dependencies: dependencies:
'@types/mdast': 3.0.15 '@types/mdast': 3.0.15
@ -8331,7 +8387,7 @@ snapshots:
mkdirp@1.0.4: {} mkdirp@1.0.4: {}
mlly@1.7.1: mlly@1.7.2:
dependencies: dependencies:
acorn: 8.12.1 acorn: 8.12.1
pathe: 1.1.2 pathe: 1.1.2
@ -8400,7 +8456,7 @@ snapshots:
fs-extra: 11.2.0 fs-extra: 11.2.0
globby: 14.0.2 globby: 14.0.2
gzip-size: 7.0.0 gzip-size: 7.0.0
h3: 1.12.0 h3: 1.13.0
hookable: 5.5.3 hookable: 5.5.3
httpxy: 0.1.5 httpxy: 0.1.5
ioredis: 5.4.1 ioredis: 5.4.1
@ -8410,7 +8466,7 @@ snapshots:
listhen: 1.7.2 listhen: 1.7.2
magic-string: 0.30.11 magic-string: 0.30.11
mime: 4.0.4 mime: 4.0.4
mlly: 1.7.1 mlly: 1.7.2
mri: 1.2.0 mri: 1.2.0
node-fetch-native: 1.6.4 node-fetch-native: 1.6.4
ofetch: 1.4.0 ofetch: 1.4.0
@ -8667,7 +8723,7 @@ snapshots:
pkg-types@1.2.0: pkg-types@1.2.0:
dependencies: dependencies:
confbox: 0.1.7 confbox: 0.1.7
mlly: 1.7.1 mlly: 1.7.2
pathe: 1.1.2 pathe: 1.1.2
pluralize@8.0.0: {} pluralize@8.0.0: {}
@ -9355,7 +9411,7 @@ snapshots:
fast-glob: 3.3.2 fast-glob: 3.3.2
local-pkg: 0.5.0 local-pkg: 0.5.0
magic-string: 0.30.11 magic-string: 0.30.11
mlly: 1.7.1 mlly: 1.7.2
pathe: 1.1.2 pathe: 1.1.2
pkg-types: 1.2.0 pkg-types: 1.2.0
scule: 1.3.0 scule: 1.3.0
@ -9397,6 +9453,20 @@ snapshots:
- rollup - rollup
- supports-color - supports-color
unplugin-auto-import@0.18.3(rollup@4.22.4):
dependencies:
'@antfu/utils': 0.7.10
'@rollup/pluginutils': 5.1.2(rollup@4.22.4)
fast-glob: 3.3.2
local-pkg: 0.5.0
magic-string: 0.30.11
minimatch: 9.0.5
unimport: 3.12.0(rollup@4.22.4)
unplugin: 1.14.1
transitivePeerDependencies:
- rollup
- webpack-sources
unplugin@1.14.1: unplugin@1.14.1:
dependencies: dependencies:
acorn: 8.12.1 acorn: 8.12.1
@ -9407,7 +9477,7 @@ snapshots:
anymatch: 3.1.3 anymatch: 3.1.3
chokidar: 3.6.0 chokidar: 3.6.0
destr: 2.0.3 destr: 2.0.3
h3: 1.12.0 h3: 1.13.0
listhen: 1.7.2 listhen: 1.7.2
lru-cache: 10.4.3 lru-cache: 10.4.3
mri: 1.2.0 mri: 1.2.0
@ -9429,7 +9499,7 @@ snapshots:
dependencies: dependencies:
knitwork: 1.1.0 knitwork: 1.1.0
magic-string: 0.30.11 magic-string: 0.30.11
mlly: 1.7.1 mlly: 1.7.2
pathe: 1.1.2 pathe: 1.1.2
pkg-types: 1.2.0 pkg-types: 1.2.0
unplugin: 1.14.1 unplugin: 1.14.1
@ -9483,7 +9553,7 @@ snapshots:
esbuild: 0.24.0 esbuild: 0.24.0
fast-glob: 3.3.2 fast-glob: 3.3.2
front-matter: 4.0.2 front-matter: 4.0.2
h3: 1.12.0 h3: 1.13.0
nitropack: 2.9.7(encoding@0.1.13)(libsql@0.4.5)(magicast@0.3.5) nitropack: 2.9.7(encoding@0.1.13)(libsql@0.4.5)(magicast@0.3.5)
vite: 5.4.8(@types/node@22.6.1)(terser@5.33.0) vite: 5.4.8(@types/node@22.6.1)(terser@5.33.0)
xmlbuilder2: 3.1.1 xmlbuilder2: 3.1.1

23
server/utils/date.test.ts Normal file
View File

@ -0,0 +1,23 @@
import { describe, expect, it } from "vitest"
describe("transform Beijing time to UTC in different timezone", () => {
const a = "2024/10/3 12:26:16"
const b = 1727929576000
it("in UTC", () => {
Object.assign(process.env, { TZ: "UTC" })
const date = tranformToUTC(a)
expect(date).toBe(b)
})
it("in Beijing", () => {
Object.assign(process.env, { TZ: "Asia/Shanghai" })
const date = tranformToUTC(a)
expect(date).toBe(b)
})
it("in New York", () => {
Object.assign(process.env, { TZ: "America/New_York" })
const date = tranformToUTC(a)
expect(date).toBe(b)
})
})

View File

@ -1,24 +1,5 @@
import { describe, expect, it } from "vitest" import { it } from "vitest"
import { tranformToUTC } from "#/utils/date"
describe("transform Beijing time to UTC in different timezone", () => { it("test", () => {
const a = "2024/10/3 12:26:16" //
const b = 1727929576000
it("in UTC", () => {
Object.assign(process.env, { TZ: "UTC" })
const date = tranformToUTC(a)
expect(date).toBe(b)
})
it("in Beijing", () => {
Object.assign(process.env, { TZ: "Asia/Shanghai" })
const date = tranformToUTC(a)
expect(date).toBe(b)
})
it("in New York", () => {
Object.assign(process.env, { TZ: "America/New_York" })
const date = tranformToUTC(a)
expect(date).toBe(b)
})
}) })

30
vitest.config.ts Normal file
View File

@ -0,0 +1,30 @@
import { defineConfig } from "vitest/config"
import autoImport from "unplugin-auto-import/vite"
import tsconfigPath from "vite-tsconfig-paths"
import { resolveModuleExportNames } from "mlly"
const h3Exports = await resolveModuleExportNames("h3", {
url: import.meta.url,
})
export default defineConfig({
test: {
globals: true,
environment: "node",
include: ["server/**/*.test.ts", "shared/**/*.test.ts"],
},
plugins: [
tsconfigPath(),
// https://github.com/unjs/nitro/blob/v2/src/core/config/resolvers/imports.ts
autoImport({
imports: ["vitest", {
from: "h3",
imports: h3Exports.filter(n => !/^[A-Z]/.test(n) && n !== "use"),
}, {
from: "ofetch",
imports: ["$fetch", "ofetch"],
}],
dirs: ["server/utils"],
}),
],
})