From 686f993ccd359b20a5743627becc12c9d834c8a6 Mon Sep 17 00:00:00 2001 From: tianyingchun Date: Wed, 12 Jun 2024 10:51:51 +0800 Subject: [PATCH] chore: imporved `Warn` --- .changeset/quiet-stingrays-jog.md | 5 + package.json | 2 +- src/tool/showWarns.ts | 5 +- src/tsconfig/getCompilerOptions.ts | 2 +- yarn.lock | 295 +---------------------------- 5 files changed, 17 insertions(+), 292 deletions(-) create mode 100644 .changeset/quiet-stingrays-jog.md diff --git a/.changeset/quiet-stingrays-jog.md b/.changeset/quiet-stingrays-jog.md new file mode 100644 index 0000000..3d3b92b --- /dev/null +++ b/.changeset/quiet-stingrays-jog.md @@ -0,0 +1,5 @@ +--- +"@hyperse/ts-node-paths": patch +--- + +imporved `Warn` diff --git a/package.json b/package.json index f2c899f..e614508 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "eslint": "^9.4.0", "execa": "^9.2.0", "husky": "9.0.11", - "lint-staged": "15.2.5", + "lint-staged": "15.2.6", "npm-run-all": "^4.1.5", "tsup": "^8.1.0", "tsx": "^4.15.2", diff --git a/src/tool/showWarns.ts b/src/tool/showWarns.ts index e69b66a..72613e7 100644 --- a/src/tool/showWarns.ts +++ b/src/tool/showWarns.ts @@ -4,10 +4,11 @@ const warns = new Map(); /** * A help to show warns only once. * @param message - The message to show. + * @param context - The context of the message. * @returns */ -export const showWarns = (message: string) => { +export const showWarns = (message: string, context?: string) => { if (warns.get(message)) return; - console.log(`${yellow('WARN')}: ${message}`); + console.log(`${yellow('WARN')}: ${message}`, context); warns.set(message, true); }; diff --git a/src/tsconfig/getCompilerOptions.ts b/src/tsconfig/getCompilerOptions.ts index b239015..093ee80 100644 --- a/src/tsconfig/getCompilerOptions.ts +++ b/src/tsconfig/getCompilerOptions.ts @@ -20,7 +20,7 @@ export function getCompilerOptions(path: string): CompilerOptions { } if (compilerOptions.baseUrl === './src') { - showWarns("`baseUrl` use './' instead of `./src`"); + showWarns("`baseUrl` use './' instead of `./src`", path); } return { diff --git a/yarn.lock b/yarn.lock index b3d8697..8abe9f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -535,13 +535,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/aix-ppc64@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/aix-ppc64@npm:0.21.4" - conditions: os=aix & cpu=ppc64 - languageName: node - linkType: hard - "@esbuild/aix-ppc64@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/aix-ppc64@npm:0.21.5" @@ -556,13 +549,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/android-arm64@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/android-arm64@npm:0.21.4" - conditions: os=android & cpu=arm64 - languageName: node - linkType: hard - "@esbuild/android-arm64@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/android-arm64@npm:0.21.5" @@ -577,13 +563,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/android-arm@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/android-arm@npm:0.21.4" - conditions: os=android & cpu=arm - languageName: node - linkType: hard - "@esbuild/android-arm@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/android-arm@npm:0.21.5" @@ -598,13 +577,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/android-x64@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/android-x64@npm:0.21.4" - conditions: os=android & cpu=x64 - languageName: node - linkType: hard - "@esbuild/android-x64@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/android-x64@npm:0.21.5" @@ -619,13 +591,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/darwin-arm64@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/darwin-arm64@npm:0.21.4" - conditions: os=darwin & cpu=arm64 - languageName: node - linkType: hard - "@esbuild/darwin-arm64@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/darwin-arm64@npm:0.21.5" @@ -640,13 +605,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/darwin-x64@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/darwin-x64@npm:0.21.4" - conditions: os=darwin & cpu=x64 - languageName: node - linkType: hard - "@esbuild/darwin-x64@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/darwin-x64@npm:0.21.5" @@ -661,13 +619,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/freebsd-arm64@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/freebsd-arm64@npm:0.21.4" - conditions: os=freebsd & cpu=arm64 - languageName: node - linkType: hard - "@esbuild/freebsd-arm64@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/freebsd-arm64@npm:0.21.5" @@ -682,13 +633,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/freebsd-x64@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/freebsd-x64@npm:0.21.4" - conditions: os=freebsd & cpu=x64 - languageName: node - linkType: hard - "@esbuild/freebsd-x64@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/freebsd-x64@npm:0.21.5" @@ -703,13 +647,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/linux-arm64@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/linux-arm64@npm:0.21.4" - conditions: os=linux & cpu=arm64 - languageName: node - linkType: hard - "@esbuild/linux-arm64@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/linux-arm64@npm:0.21.5" @@ -724,13 +661,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/linux-arm@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/linux-arm@npm:0.21.4" - conditions: os=linux & cpu=arm - languageName: node - linkType: hard - "@esbuild/linux-arm@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/linux-arm@npm:0.21.5" @@ -745,13 +675,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/linux-ia32@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/linux-ia32@npm:0.21.4" - conditions: os=linux & cpu=ia32 - languageName: node - linkType: hard - "@esbuild/linux-ia32@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/linux-ia32@npm:0.21.5" @@ -766,13 +689,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/linux-loong64@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/linux-loong64@npm:0.21.4" - conditions: os=linux & cpu=loong64 - languageName: node - linkType: hard - "@esbuild/linux-loong64@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/linux-loong64@npm:0.21.5" @@ -787,13 +703,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/linux-mips64el@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/linux-mips64el@npm:0.21.4" - conditions: os=linux & cpu=mips64el - languageName: node - linkType: hard - "@esbuild/linux-mips64el@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/linux-mips64el@npm:0.21.5" @@ -808,13 +717,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/linux-ppc64@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/linux-ppc64@npm:0.21.4" - conditions: os=linux & cpu=ppc64 - languageName: node - linkType: hard - "@esbuild/linux-ppc64@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/linux-ppc64@npm:0.21.5" @@ -829,13 +731,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/linux-riscv64@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/linux-riscv64@npm:0.21.4" - conditions: os=linux & cpu=riscv64 - languageName: node - linkType: hard - "@esbuild/linux-riscv64@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/linux-riscv64@npm:0.21.5" @@ -850,13 +745,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/linux-s390x@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/linux-s390x@npm:0.21.4" - conditions: os=linux & cpu=s390x - languageName: node - linkType: hard - "@esbuild/linux-s390x@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/linux-s390x@npm:0.21.5" @@ -871,13 +759,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/linux-x64@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/linux-x64@npm:0.21.4" - conditions: os=linux & cpu=x64 - languageName: node - linkType: hard - "@esbuild/linux-x64@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/linux-x64@npm:0.21.5" @@ -892,13 +773,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/netbsd-x64@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/netbsd-x64@npm:0.21.4" - conditions: os=netbsd & cpu=x64 - languageName: node - linkType: hard - "@esbuild/netbsd-x64@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/netbsd-x64@npm:0.21.5" @@ -913,13 +787,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/openbsd-x64@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/openbsd-x64@npm:0.21.4" - conditions: os=openbsd & cpu=x64 - languageName: node - linkType: hard - "@esbuild/openbsd-x64@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/openbsd-x64@npm:0.21.5" @@ -934,13 +801,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/sunos-x64@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/sunos-x64@npm:0.21.4" - conditions: os=sunos & cpu=x64 - languageName: node - linkType: hard - "@esbuild/sunos-x64@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/sunos-x64@npm:0.21.5" @@ -955,13 +815,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/win32-arm64@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/win32-arm64@npm:0.21.4" - conditions: os=win32 & cpu=arm64 - languageName: node - linkType: hard - "@esbuild/win32-arm64@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/win32-arm64@npm:0.21.5" @@ -976,13 +829,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/win32-ia32@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/win32-ia32@npm:0.21.4" - conditions: os=win32 & cpu=ia32 - languageName: node - linkType: hard - "@esbuild/win32-ia32@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/win32-ia32@npm:0.21.5" @@ -997,13 +843,6 @@ __metadata: languageName: node linkType: hard -"@esbuild/win32-x64@npm:0.21.4": - version: 0.21.4 - resolution: "@esbuild/win32-x64@npm:0.21.4" - conditions: os=win32 & cpu=x64 - languageName: node - linkType: hard - "@esbuild/win32-x64@npm:0.21.5": version: 0.21.5 resolution: "@esbuild/win32-x64@npm:0.21.5" @@ -1132,7 +971,7 @@ __metadata: execa: "npm:^9.2.0" get-tsconfig: "npm:^4.7.5" husky: "npm:9.0.11" - lint-staged: "npm:15.2.5" + lint-staged: "npm:15.2.6" npm-run-all: "npm:^4.1.5" package-up: "npm:^5.0.0" ts-node: "npm:11.0.0-beta.1" @@ -3478,87 +3317,7 @@ __metadata: languageName: node linkType: hard -"esbuild@npm:^0.21.4": - version: 0.21.4 - resolution: "esbuild@npm:0.21.4" - dependencies: - "@esbuild/aix-ppc64": "npm:0.21.4" - "@esbuild/android-arm": "npm:0.21.4" - "@esbuild/android-arm64": "npm:0.21.4" - "@esbuild/android-x64": "npm:0.21.4" - "@esbuild/darwin-arm64": "npm:0.21.4" - "@esbuild/darwin-x64": "npm:0.21.4" - "@esbuild/freebsd-arm64": "npm:0.21.4" - "@esbuild/freebsd-x64": "npm:0.21.4" - "@esbuild/linux-arm": "npm:0.21.4" - "@esbuild/linux-arm64": "npm:0.21.4" - "@esbuild/linux-ia32": "npm:0.21.4" - "@esbuild/linux-loong64": "npm:0.21.4" - "@esbuild/linux-mips64el": "npm:0.21.4" - "@esbuild/linux-ppc64": "npm:0.21.4" - "@esbuild/linux-riscv64": "npm:0.21.4" - "@esbuild/linux-s390x": "npm:0.21.4" - "@esbuild/linux-x64": "npm:0.21.4" - "@esbuild/netbsd-x64": "npm:0.21.4" - "@esbuild/openbsd-x64": "npm:0.21.4" - "@esbuild/sunos-x64": "npm:0.21.4" - "@esbuild/win32-arm64": "npm:0.21.4" - "@esbuild/win32-ia32": "npm:0.21.4" - "@esbuild/win32-x64": "npm:0.21.4" - dependenciesMeta: - "@esbuild/aix-ppc64": - optional: true - "@esbuild/android-arm": - optional: true - "@esbuild/android-arm64": - optional: true - "@esbuild/android-x64": - optional: true - "@esbuild/darwin-arm64": - optional: true - "@esbuild/darwin-x64": - optional: true - "@esbuild/freebsd-arm64": - optional: true - "@esbuild/freebsd-x64": - optional: true - "@esbuild/linux-arm": - optional: true - "@esbuild/linux-arm64": - optional: true - "@esbuild/linux-ia32": - optional: true - "@esbuild/linux-loong64": - optional: true - "@esbuild/linux-mips64el": - optional: true - "@esbuild/linux-ppc64": - optional: true - "@esbuild/linux-riscv64": - optional: true - "@esbuild/linux-s390x": - optional: true - "@esbuild/linux-x64": - optional: true - "@esbuild/netbsd-x64": - optional: true - "@esbuild/openbsd-x64": - optional: true - "@esbuild/sunos-x64": - optional: true - "@esbuild/win32-arm64": - optional: true - "@esbuild/win32-ia32": - optional: true - "@esbuild/win32-x64": - optional: true - bin: - esbuild: bin/esbuild - checksum: 10/d27b0fcdce514a73a10c6a687b3d2a90280d9ff07414a8d8b643f2be4e794f992f94de9044a5be90a9be07f368421e1b05d07209822f8f1a33ce47a18df2ebe8 - languageName: node - linkType: hard - -"esbuild@npm:~0.21.4": +"esbuild@npm:^0.21.4, esbuild@npm:~0.21.4": version: 0.21.5 resolution: "esbuild@npm:0.21.5" dependencies: @@ -5680,9 +5439,9 @@ __metadata: languageName: node linkType: hard -"lint-staged@npm:15.2.5": - version: 15.2.5 - resolution: "lint-staged@npm:15.2.5" +"lint-staged@npm:15.2.6": + version: 15.2.6 + resolution: "lint-staged@npm:15.2.6" dependencies: chalk: "npm:~5.3.0" commander: "npm:~12.1.0" @@ -5696,7 +5455,7 @@ __metadata: yaml: "npm:~2.4.2" bin: lint-staged: bin/lint-staged.js - checksum: 10/2cb8e14e532a4de0a338da44dc5e22f94581390b988ba3d345d1132d592d9ce50be50846c9a9d25eaffaf3f1f634e0a056598f6abb705269ac21d0fd3bad3a45 + checksum: 10/d2e7b610603ace80521d80afa7d355864a0f5f574aa2a2edbf5d96486e99ceeebb4d988e733c0b6ad8bfa899092f1c20db5cb02a0cc3e260919aeb92ef6f2d79 languageName: node linkType: hard @@ -9473,47 +9232,7 @@ __metadata: languageName: node linkType: hard -"vite@npm:^5.0.0": - version: 5.2.12 - resolution: "vite@npm:5.2.12" - dependencies: - esbuild: "npm:^0.20.1" - fsevents: "npm:~2.3.3" - postcss: "npm:^8.4.38" - rollup: "npm:^4.13.0" - peerDependencies: - "@types/node": ^18.0.0 || >=20.0.0 - less: "*" - lightningcss: ^1.21.0 - sass: "*" - stylus: "*" - sugarss: "*" - terser: ^5.4.0 - dependenciesMeta: - fsevents: - optional: true - peerDependenciesMeta: - "@types/node": - optional: true - less: - optional: true - lightningcss: - optional: true - sass: - optional: true - stylus: - optional: true - sugarss: - optional: true - terser: - optional: true - bin: - vite: bin/vite.js - checksum: 10/c27d3efff93016e8171b6a362f605ad5f78e24086292987097ad4a7382ae78d9e0659065976a13bf7b51ba0f593d675579010692097ef36d8a5cc965f3efec4c - languageName: node - linkType: hard - -"vite@npm:^5.2.13": +"vite@npm:^5.0.0, vite@npm:^5.2.13": version: 5.2.13 resolution: "vite@npm:5.2.13" dependencies: