hardhat 3.4.1 → 3.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/dist/src/cli.js +5 -5
  3. package/dist/src/cli.js.map +1 -1
  4. package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.d.ts.map +1 -1
  5. package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.js +10 -3
  6. package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.js.map +1 -1
  7. package/dist/src/internal/builtin-plugins/console/task-action.js +4 -4
  8. package/dist/src/internal/builtin-plugins/console/task-action.js.map +1 -1
  9. package/dist/src/internal/builtin-plugins/coverage/coverage-manager.js +7 -7
  10. package/dist/src/internal/builtin-plugins/coverage/coverage-manager.js.map +1 -1
  11. package/dist/src/internal/builtin-plugins/coverage/exports.d.ts +1 -1
  12. package/dist/src/internal/builtin-plugins/coverage/exports.d.ts.map +1 -1
  13. package/dist/src/internal/builtin-plugins/coverage/exports.js +1 -1
  14. package/dist/src/internal/builtin-plugins/coverage/exports.js.map +1 -1
  15. package/dist/src/internal/builtin-plugins/coverage/helpers/accessors.d.ts +7 -0
  16. package/dist/src/internal/builtin-plugins/coverage/helpers/accessors.d.ts.map +1 -0
  17. package/dist/src/internal/builtin-plugins/coverage/helpers/accessors.js +24 -0
  18. package/dist/src/internal/builtin-plugins/coverage/helpers/accessors.js.map +1 -0
  19. package/dist/src/internal/builtin-plugins/coverage/helpers/compat.d.ts +4 -0
  20. package/dist/src/internal/builtin-plugins/coverage/helpers/compat.d.ts.map +1 -0
  21. package/dist/src/internal/builtin-plugins/coverage/helpers/compat.js +27 -0
  22. package/dist/src/internal/builtin-plugins/coverage/helpers/compat.js.map +1 -0
  23. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/clean.js +1 -1
  24. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/clean.js.map +1 -1
  25. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/hre.d.ts.map +1 -1
  26. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/hre.js +18 -15
  27. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/hre.js.map +1 -1
  28. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js +3 -3
  29. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js.map +1 -1
  30. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.js +1 -1
  31. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.js.map +1 -1
  32. package/dist/src/internal/builtin-plugins/coverage/instrumentation.d.ts.map +1 -1
  33. package/dist/src/internal/builtin-plugins/coverage/instrumentation.js +7 -2
  34. package/dist/src/internal/builtin-plugins/coverage/instrumentation.js.map +1 -1
  35. package/dist/src/internal/builtin-plugins/coverage/process-coverage.js +6 -6
  36. package/dist/src/internal/builtin-plugins/coverage/process-coverage.js.map +1 -1
  37. package/dist/src/internal/builtin-plugins/flatten/task-action.d.ts.map +1 -1
  38. package/dist/src/internal/builtin-plugins/flatten/task-action.js +4 -4
  39. package/dist/src/internal/builtin-plugins/flatten/task-action.js.map +1 -1
  40. package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.d.ts.map +1 -1
  41. package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.js +10 -10
  42. package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.js.map +1 -1
  43. package/dist/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.d.ts.map +1 -1
  44. package/dist/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.js +12 -9
  45. package/dist/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.js.map +1 -1
  46. package/dist/src/internal/builtin-plugins/gas-analytics/helpers/accessors.d.ts.map +1 -1
  47. package/dist/src/internal/builtin-plugins/gas-analytics/helpers/accessors.js +10 -4
  48. package/dist/src/internal/builtin-plugins/gas-analytics/helpers/accessors.js.map +1 -1
  49. package/dist/src/internal/builtin-plugins/gas-analytics/helpers/utils.js +2 -2
  50. package/dist/src/internal/builtin-plugins/gas-analytics/helpers/utils.js.map +1 -1
  51. package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.d.ts.map +1 -1
  52. package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.js +18 -14
  53. package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.js.map +1 -1
  54. package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.d.ts.map +1 -1
  55. package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.js +11 -16
  56. package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.js.map +1 -1
  57. package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.d.ts.map +1 -1
  58. package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.js +5 -5
  59. package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.js.map +1 -1
  60. package/dist/src/internal/builtin-plugins/network-manager/config-resolution.js +1 -1
  61. package/dist/src/internal/builtin-plugins/network-manager/config-resolution.js.map +1 -1
  62. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.d.ts +14 -0
  63. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.d.ts.map +1 -0
  64. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.js +40 -0
  65. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.js.map +1 -0
  66. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.d.ts +1 -12
  67. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.d.ts.map +1 -1
  68. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js +2 -41
  69. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js.map +1 -1
  70. package/dist/src/internal/builtin-plugins/network-manager/edr/types/hardfork.d.ts.map +1 -1
  71. package/dist/src/internal/builtin-plugins/network-manager/edr/types/hardfork.js +2 -5
  72. package/dist/src/internal/builtin-plugins/network-manager/edr/types/hardfork.js.map +1 -1
  73. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js +1 -1
  74. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js.map +1 -1
  75. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.d.ts +2 -2
  76. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.d.ts.map +1 -1
  77. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.js +21 -24
  78. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.js.map +1 -1
  79. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.d.ts.map +1 -1
  80. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.js +13 -11
  81. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.js.map +1 -1
  82. package/dist/src/internal/builtin-plugins/node/artifacts/build-info-watcher.js +2 -2
  83. package/dist/src/internal/builtin-plugins/node/artifacts/build-info-watcher.js.map +1 -1
  84. package/dist/src/internal/builtin-plugins/node/helpers.d.ts +2 -1
  85. package/dist/src/internal/builtin-plugins/node/helpers.d.ts.map +1 -1
  86. package/dist/src/internal/builtin-plugins/node/helpers.js +4 -4
  87. package/dist/src/internal/builtin-plugins/node/helpers.js.map +1 -1
  88. package/dist/src/internal/builtin-plugins/node/json-rpc/server.js +2 -2
  89. package/dist/src/internal/builtin-plugins/node/json-rpc/server.js.map +1 -1
  90. package/dist/src/internal/builtin-plugins/node/task-action.d.ts.map +1 -1
  91. package/dist/src/internal/builtin-plugins/node/task-action.js +4 -4
  92. package/dist/src/internal/builtin-plugins/node/task-action.js.map +1 -1
  93. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts.map +1 -1
  94. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js +68 -29
  95. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.map +1 -1
  96. package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.d.ts +8 -0
  97. package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.d.ts.map +1 -0
  98. package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.js +46 -0
  99. package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.js.map +1 -0
  100. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.d.ts.map +1 -1
  101. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.js +9 -3
  102. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.js.map +1 -1
  103. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.d.ts.map +1 -1
  104. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.js +2 -2
  105. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.js.map +1 -1
  106. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/index.js +2 -2
  107. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/index.js.map +1 -1
  108. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-wrapper.d.ts.map +1 -1
  109. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-wrapper.js +7 -19
  110. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-wrapper.js.map +1 -1
  111. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.d.ts.map +1 -1
  112. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.js +4 -3
  113. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.js.map +1 -1
  114. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/utils.d.ts +2 -1
  115. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/utils.d.ts.map +1 -1
  116. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/utils.js +12 -8
  117. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/utils.js.map +1 -1
  118. package/dist/src/internal/builtin-plugins/solidity/build-system/solc-info.d.ts +3 -2
  119. package/dist/src/internal/builtin-plugins/solidity/build-system/solc-info.d.ts.map +1 -1
  120. package/dist/src/internal/builtin-plugins/solidity/build-system/solc-info.js +15 -6
  121. package/dist/src/internal/builtin-plugins/solidity/build-system/solc-info.js.map +1 -1
  122. package/dist/src/internal/builtin-plugins/solidity/config.d.ts.map +1 -1
  123. package/dist/src/internal/builtin-plugins/solidity/config.js +2 -2
  124. package/dist/src/internal/builtin-plugins/solidity/config.js.map +1 -1
  125. package/dist/src/internal/builtin-plugins/solidity/constants.d.ts +1 -0
  126. package/dist/src/internal/builtin-plugins/solidity/constants.d.ts.map +1 -1
  127. package/dist/src/internal/builtin-plugins/solidity/constants.js +2 -0
  128. package/dist/src/internal/builtin-plugins/solidity/constants.js.map +1 -1
  129. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.d.ts.map +1 -1
  130. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js +6 -1
  131. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js.map +1 -1
  132. package/dist/src/internal/builtin-plugins/solidity-test/config.d.ts.map +1 -1
  133. package/dist/src/internal/builtin-plugins/solidity-test/config.js +1 -0
  134. package/dist/src/internal/builtin-plugins/solidity-test/config.js.map +1 -1
  135. package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts +1 -2
  136. package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts.map +1 -1
  137. package/dist/src/internal/builtin-plugins/solidity-test/helpers.js +3 -3
  138. package/dist/src/internal/builtin-plugins/solidity-test/helpers.js.map +1 -1
  139. package/dist/src/internal/builtin-plugins/solidity-test/reporter.d.ts +2 -2
  140. package/dist/src/internal/builtin-plugins/solidity-test/reporter.d.ts.map +1 -1
  141. package/dist/src/internal/builtin-plugins/solidity-test/reporter.js +19 -17
  142. package/dist/src/internal/builtin-plugins/solidity-test/reporter.js.map +1 -1
  143. package/dist/src/internal/builtin-plugins/solidity-test/task-action.d.ts.map +1 -1
  144. package/dist/src/internal/builtin-plugins/solidity-test/task-action.js +6 -3
  145. package/dist/src/internal/builtin-plugins/solidity-test/task-action.js.map +1 -1
  146. package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts +1 -0
  147. package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts.map +1 -1
  148. package/dist/src/internal/builtin-plugins/test/task-action.d.ts.map +1 -1
  149. package/dist/src/internal/builtin-plugins/test/task-action.js +9 -7
  150. package/dist/src/internal/builtin-plugins/test/task-action.js.map +1 -1
  151. package/dist/src/internal/cli/banner-manager.js +2 -2
  152. package/dist/src/internal/cli/banner-manager.js.map +1 -1
  153. package/dist/src/internal/cli/error-handler.d.ts.map +1 -1
  154. package/dist/src/internal/cli/error-handler.js +6 -6
  155. package/dist/src/internal/cli/error-handler.js.map +1 -1
  156. package/dist/src/internal/cli/help/get-help-string.js +2 -2
  157. package/dist/src/internal/cli/help/get-help-string.js.map +1 -1
  158. package/dist/src/internal/cli/init/init.d.ts.map +1 -1
  159. package/dist/src/internal/cli/init/init.js +57 -36
  160. package/dist/src/internal/cli/init/init.js.map +1 -1
  161. package/dist/src/internal/cli/init/package-manager.d.ts.map +1 -1
  162. package/dist/src/internal/cli/init/package-manager.js +5 -5
  163. package/dist/src/internal/cli/init/package-manager.js.map +1 -1
  164. package/dist/src/internal/cli/init/prompt.d.ts.map +1 -1
  165. package/dist/src/internal/cli/init/prompt.js +3 -3
  166. package/dist/src/internal/cli/init/prompt.js.map +1 -1
  167. package/dist/src/internal/cli/init/template.d.ts.map +1 -1
  168. package/dist/src/internal/cli/init/template.js +5 -14
  169. package/dist/src/internal/cli/init/template.js.map +1 -1
  170. package/dist/src/internal/cli/main.d.ts.map +1 -1
  171. package/dist/src/internal/cli/main.js +2 -2
  172. package/dist/src/internal/cli/main.js.map +1 -1
  173. package/dist/src/internal/cli/node-version.d.ts +1 -1
  174. package/dist/src/internal/cli/node-version.d.ts.map +1 -1
  175. package/dist/src/internal/cli/node-version.js +17 -10
  176. package/dist/src/internal/cli/node-version.js.map +1 -1
  177. package/dist/src/internal/cli/telemetry/analytics/analytics.js +2 -2
  178. package/dist/src/internal/cli/telemetry/analytics/analytics.js.map +1 -1
  179. package/dist/src/internal/cli/telemetry/analytics/utils.js +2 -2
  180. package/dist/src/internal/cli/telemetry/analytics/utils.js.map +1 -1
  181. package/dist/src/internal/cli/telemetry/error-reporter/global-error-handlers.js +2 -2
  182. package/dist/src/internal/cli/telemetry/error-reporter/global-error-handlers.js.map +1 -1
  183. package/dist/src/internal/cli/telemetry/sentry/reporter.js +2 -2
  184. package/dist/src/internal/cli/telemetry/sentry/reporter.js.map +1 -1
  185. package/dist/src/internal/cli/telemetry/sentry/subprocess.js +2 -2
  186. package/dist/src/internal/cli/telemetry/sentry/subprocess.js.map +1 -1
  187. package/dist/src/internal/cli/telemetry/sentry/transport.js +2 -2
  188. package/dist/src/internal/cli/telemetry/sentry/transport.js.map +1 -1
  189. package/dist/src/internal/cli/telemetry/telemetry-permissions.js +2 -2
  190. package/dist/src/internal/cli/telemetry/telemetry-permissions.js.map +1 -1
  191. package/dist/src/internal/config-loading.js +2 -2
  192. package/dist/src/internal/config-loading.js.map +1 -1
  193. package/dist/src/internal/core/hook-manager.d.ts.map +1 -1
  194. package/dist/src/internal/core/hook-manager.js +202 -58
  195. package/dist/src/internal/core/hook-manager.js.map +1 -1
  196. package/dist/src/internal/core/hre.js +2 -2
  197. package/dist/src/internal/core/hre.js.map +1 -1
  198. package/dist/src/internal/core/lazy-user-interruptions.d.ts +11 -0
  199. package/dist/src/internal/core/lazy-user-interruptions.d.ts.map +1 -0
  200. package/dist/src/internal/core/lazy-user-interruptions.js +39 -0
  201. package/dist/src/internal/core/lazy-user-interruptions.js.map +1 -0
  202. package/dist/src/internal/core/user-interruptions.js +4 -4
  203. package/dist/src/internal/core/user-interruptions.js.map +1 -1
  204. package/dist/src/internal/using-hardhat2-plugin-errors.d.ts.map +1 -1
  205. package/dist/src/internal/using-hardhat2-plugin-errors.js +2 -2
  206. package/dist/src/internal/using-hardhat2-plugin-errors.js.map +1 -1
  207. package/package.json +6 -9
  208. package/src/cli.ts +5 -5
  209. package/src/internal/builtin-plugins/artifacts/artifact-manager.ts +12 -5
  210. package/src/internal/builtin-plugins/console/task-action.ts +4 -4
  211. package/src/internal/builtin-plugins/coverage/coverage-manager.ts +7 -7
  212. package/src/internal/builtin-plugins/coverage/exports.ts +1 -1
  213. package/src/internal/builtin-plugins/coverage/helpers/accessors.ts +44 -0
  214. package/src/internal/builtin-plugins/coverage/helpers/compat.ts +37 -0
  215. package/src/internal/builtin-plugins/coverage/hook-handlers/clean.ts +1 -1
  216. package/src/internal/builtin-plugins/coverage/hook-handlers/hre.ts +26 -16
  217. package/src/internal/builtin-plugins/coverage/hook-handlers/solidity.ts +3 -3
  218. package/src/internal/builtin-plugins/coverage/hook-handlers/test.ts +1 -1
  219. package/src/internal/builtin-plugins/coverage/instrumentation.ts +21 -2
  220. package/src/internal/builtin-plugins/coverage/process-coverage.ts +6 -6
  221. package/src/internal/builtin-plugins/flatten/task-action.ts +8 -4
  222. package/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.ts +11 -10
  223. package/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.ts +13 -9
  224. package/src/internal/builtin-plugins/gas-analytics/helpers/accessors.ts +12 -5
  225. package/src/internal/builtin-plugins/gas-analytics/helpers/utils.ts +2 -2
  226. package/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.ts +29 -17
  227. package/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.ts +12 -15
  228. package/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.ts +11 -5
  229. package/src/internal/builtin-plugins/network-manager/config-resolution.ts +1 -1
  230. package/src/internal/builtin-plugins/network-manager/edr/edr-constants.ts +61 -0
  231. package/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts +2 -61
  232. package/src/internal/builtin-plugins/network-manager/edr/types/hardfork.ts +3 -9
  233. package/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.ts +1 -1
  234. package/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.ts +23 -23
  235. package/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.ts +14 -11
  236. package/src/internal/builtin-plugins/node/artifacts/build-info-watcher.ts +2 -2
  237. package/src/internal/builtin-plugins/node/helpers.ts +8 -5
  238. package/src/internal/builtin-plugins/node/json-rpc/server.ts +2 -2
  239. package/src/internal/builtin-plugins/node/task-action.ts +5 -4
  240. package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +92 -52
  241. package/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.ts +61 -0
  242. package/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.ts +17 -3
  243. package/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts +4 -2
  244. package/src/internal/builtin-plugins/solidity/build-system/compiler/index.ts +2 -2
  245. package/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-wrapper.ts +19 -22
  246. package/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.ts +9 -1
  247. package/src/internal/builtin-plugins/solidity/build-system/resolver/utils.ts +16 -7
  248. package/src/internal/builtin-plugins/solidity/build-system/solc-info.ts +27 -6
  249. package/src/internal/builtin-plugins/solidity/config.ts +5 -2
  250. package/src/internal/builtin-plugins/solidity/constants.ts +3 -0
  251. package/src/internal/builtin-plugins/solidity/hook-handlers/hre.ts +13 -4
  252. package/src/internal/builtin-plugins/solidity-test/config.ts +1 -0
  253. package/src/internal/builtin-plugins/solidity-test/helpers.ts +3 -4
  254. package/src/internal/builtin-plugins/solidity-test/reporter.ts +19 -18
  255. package/src/internal/builtin-plugins/solidity-test/task-action.ts +6 -3
  256. package/src/internal/builtin-plugins/solidity-test/type-extensions.ts +1 -0
  257. package/src/internal/builtin-plugins/test/task-action.ts +13 -7
  258. package/src/internal/cli/banner-manager.ts +2 -2
  259. package/src/internal/cli/error-handler.ts +10 -6
  260. package/src/internal/cli/help/get-help-string.ts +2 -2
  261. package/src/internal/cli/init/init.ts +86 -43
  262. package/src/internal/cli/init/package-manager.ts +8 -6
  263. package/src/internal/cli/init/prompt.ts +4 -3
  264. package/src/internal/cli/init/template.ts +22 -27
  265. package/src/internal/cli/main.ts +4 -3
  266. package/src/internal/cli/node-version.ts +20 -12
  267. package/src/internal/cli/telemetry/analytics/analytics.ts +2 -2
  268. package/src/internal/cli/telemetry/analytics/utils.ts +2 -2
  269. package/src/internal/cli/telemetry/error-reporter/global-error-handlers.ts +2 -2
  270. package/src/internal/cli/telemetry/sentry/reporter.ts +2 -2
  271. package/src/internal/cli/telemetry/sentry/subprocess.ts +2 -2
  272. package/src/internal/cli/telemetry/sentry/transport.ts +2 -2
  273. package/src/internal/cli/telemetry/telemetry-permissions.ts +2 -2
  274. package/src/internal/config-loading.ts +2 -2
  275. package/src/internal/core/hook-manager.ts +283 -101
  276. package/src/internal/core/hre.ts +2 -2
  277. package/src/internal/core/lazy-user-interruptions.ts +75 -0
  278. package/src/internal/core/user-interruptions.ts +4 -4
  279. package/src/internal/using-hardhat2-plugin-errors.ts +2 -2
  280. package/templates/hardhat-3/01-node-test-runner-viem/package.json +7 -7
  281. package/templates/hardhat-3/02-mocha-ethers/package.json +13 -13
  282. package/templates/hardhat-3/03-minimal/package.json +1 -1
  283. package/dist/src/internal/builtin-plugins/coverage/helpers.d.ts +0 -15
  284. package/dist/src/internal/builtin-plugins/coverage/helpers.d.ts.map +0 -1
  285. package/dist/src/internal/builtin-plugins/coverage/helpers.js +0 -35
  286. package/dist/src/internal/builtin-plugins/coverage/helpers.js.map +0 -1
  287. package/dist/src/internal/utils/colorizer.d.ts +0 -10
  288. package/dist/src/internal/utils/colorizer.d.ts.map +0 -1
  289. package/dist/src/internal/utils/colorizer.js +0 -2
  290. package/dist/src/internal/utils/colorizer.js.map +0 -1
  291. package/src/internal/builtin-plugins/coverage/helpers.ts +0 -63
  292. package/src/internal/utils/colorizer.ts +0 -9
@@ -1,8 +1,9 @@
1
+ import { styleText } from "node:util";
2
+
1
3
  import {
2
4
  HardhatError,
3
5
  HardhatPluginError,
4
6
  } from "@nomicfoundation/hardhat-errors";
5
- import chalk from "chalk";
6
7
 
7
8
  import { HARDHAT_NAME, HARDHAT_WEBSITE_URL } from "../constants.js";
8
9
  import { UsingHardhat2PluginError } from "../using-hardhat2-plugin-errors.js";
@@ -132,22 +133,25 @@ function getErrorMessages(error: Error): ErrorMessages {
132
133
  switch (category) {
133
134
  case ErrorCategory.HARDHAT:
134
135
  return {
135
- formattedErrorMessage: `${chalk.red.bold(`Error ${categorizedError.errorCode}:`)} ${categorizedError.formattedMessage}`,
136
+ formattedErrorMessage: `${styleText(["red", "bold"], `Error ${categorizedError.errorCode}:`)} ${categorizedError.formattedMessage}`,
136
137
  showMoreInfoMessage: `For more info go to ${HARDHAT_WEBSITE_URL}${categorizedError.errorCode} or run ${HARDHAT_NAME} with --show-stack-traces`,
137
138
  };
138
139
  case ErrorCategory.PLUGIN:
139
140
  return {
140
- formattedErrorMessage: `${chalk.red.bold(`Error ${categorizedError.errorCode} in plugin ${categorizedError.pluginId}:`)} ${categorizedError.formattedMessage}`,
141
+ formattedErrorMessage: `${styleText(["red", "bold"], `Error ${categorizedError.errorCode} in plugin ${categorizedError.pluginId}:`)} ${categorizedError.formattedMessage}`,
141
142
  showMoreInfoMessage: `For more info go to ${HARDHAT_WEBSITE_URL}${categorizedError.errorCode} or run ${HARDHAT_NAME} with --show-stack-traces`,
142
143
  };
143
144
  case ErrorCategory.COMMUNITY_PLUGIN:
144
145
  return {
145
- formattedErrorMessage: `${chalk.red.bold(`Error in community plugin ${categorizedError.pluginId}:`)} ${categorizedError.message}`,
146
+ formattedErrorMessage: `${styleText(["red", "bold"], `Error in community plugin ${categorizedError.pluginId}:`)} ${categorizedError.message}`,
146
147
  showMoreInfoMessage: `For more info run ${HARDHAT_NAME} with --show-stack-traces`,
147
148
  };
148
149
  case ErrorCategory.OTHER:
149
150
  return {
150
- formattedErrorMessage: chalk.red.bold(`An unexpected error occurred:`),
151
+ formattedErrorMessage: styleText(
152
+ ["red", "bold"],
153
+ `An unexpected error occurred:`,
154
+ ),
151
155
  postErrorStackTraceMessage: `If you think this is a bug in Hardhat, please report it here: ${HARDHAT_WEBSITE_URL}report-bug`,
152
156
  };
153
157
  }
@@ -156,7 +160,7 @@ function printUsingHardhat2Error(
156
160
  error: UsingHardhat2PluginError,
157
161
  print: (message: string | Error) => void = console.error,
158
162
  ): void {
159
- print(chalk.red.bold(`Hardhat 3 installation error:`));
163
+ print(styleText(["red", "bold"], `Hardhat 3 installation error:`));
160
164
  print("");
161
165
  if (error.callerRelativePath !== undefined) {
162
166
  print(error.message);
@@ -1,7 +1,7 @@
1
1
  import type { GlobalOptionDefinitions } from "../../../types/global-options.js";
2
2
  import type { Task } from "../../../types/tasks.js";
3
3
 
4
- import chalk from "chalk";
4
+ import { styleText } from "node:util";
5
5
 
6
6
  import {
7
7
  GLOBAL_NAME_PADDING,
@@ -31,7 +31,7 @@ export async function getHelpString(
31
31
  ...globalOptions,
32
32
  ]) + GLOBAL_NAME_PADDING;
33
33
 
34
- let output = `${chalk.bold(task.description)}`;
34
+ let output = `${styleText("bold", task.description)}`;
35
35
 
36
36
  if (task.isEmpty) {
37
37
  output += `\n\nUsage: hardhat [GLOBAL OPTIONS] ${task.id.join(" ")} <SUBTASK> [SUBTASK OPTIONS] [--] [SUBTASK POSITIONAL ARGUMENTS]\n`;
@@ -2,25 +2,24 @@ import type { Template } from "./template.js";
2
2
  import type { PackageJson } from "@nomicfoundation/hardhat-utils/package";
3
3
 
4
4
  import path from "node:path";
5
+ import { styleText } from "node:util";
5
6
 
6
7
  import {
7
8
  assertHardhatInvariant,
8
9
  HardhatError,
9
10
  } from "@nomicfoundation/hardhat-errors";
11
+ import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
10
12
  import { ensureError } from "@nomicfoundation/hardhat-utils/error";
11
13
  import {
12
14
  copy,
13
15
  ensureDir,
14
16
  exists,
15
- getAllFilesMatching,
16
17
  isDirectory,
17
18
  mkdir,
18
19
  readJsonFile,
19
20
  writeJsonFile,
20
21
  } from "@nomicfoundation/hardhat-utils/fs";
21
22
  import { resolveFromRoot } from "@nomicfoundation/hardhat-utils/path";
22
- import chalk from "chalk";
23
- import debug from "debug";
24
23
  import * as semver from "semver";
25
24
 
26
25
  import { findClosestHardhatConfig } from "../../config-loading.js";
@@ -59,7 +58,7 @@ export interface InitHardhatOptions {
59
58
  install?: boolean;
60
59
  }
61
60
 
62
- const log = debug("hardhat:cli:init");
61
+ const log = createDebug("hardhat:core:cli:init");
63
62
 
64
63
  /**
65
64
  * initHardhat implements the project initialization wizard flow.
@@ -166,7 +165,7 @@ function printAsciiLogo() {
166
165
  // logo doesn't fit
167
166
  process.stdout.write("\x1b[?7l");
168
167
 
169
- console.log(chalk.blue(logoLines));
168
+ console.log(styleText("blue", logoLines));
170
169
 
171
170
  // Re-enable auto-wapping
172
171
  process.stdout.write("\x1b[?7h");
@@ -177,7 +176,7 @@ export async function printWelcomeMessage(): Promise<void> {
177
176
  const hardhatVersion = await getHardhatVersion();
178
177
 
179
178
  console.log(
180
- chalk.cyan(`👷 Welcome to ${HARDHAT_NAME} v${hardhatVersion} 👷\n`),
179
+ styleText("cyan", `👷 Welcome to ${HARDHAT_NAME} v${hardhatVersion} 👷\n`),
181
180
  );
182
181
 
183
182
  // Warn the user if they are using an outdated version of Hardhat
@@ -185,7 +184,8 @@ export async function printWelcomeMessage(): Promise<void> {
185
184
  const latestHardhatVersion = await getLatestHardhatVersion();
186
185
  if (hardhatVersion !== latestHardhatVersion) {
187
186
  console.warn(
188
- chalk.yellow.bold(
187
+ styleText(
188
+ ["yellow", "bold"],
189
189
  `⚠️ You are using an outdated version of Hardhat. The latest version is v${latestHardhatVersion}. Please consider upgrading to the latest version before continuing with the project initialization. ⚠️\n`,
190
190
  ),
191
191
  );
@@ -198,7 +198,8 @@ export async function printWelcomeMessage(): Promise<void> {
198
198
  log("Couldn't report error to sentry: %O", e);
199
199
  }
200
200
  console.warn(
201
- chalk.yellow.bold(
201
+ styleText(
202
+ ["yellow", "bold"],
202
203
  `⚠️ We couldn't check if you are using the latest version of Hardhat. Please consider upgrading to the latest version if you are not using it yet. ⚠️\n`,
203
204
  ),
204
205
  );
@@ -435,17 +436,36 @@ export async function copyProjectFiles(
435
436
  template: Template,
436
437
  force?: boolean,
437
438
  ): Promise<void> {
438
- // Find all the files in the workspace that would have been overwritten by the template files
439
- const matchingRelativeWorkspacePaths = await getAllFilesMatching(
440
- workspace,
441
- (file) => {
442
- const relativeWorkspacePath = path.relative(workspace, file);
443
- const relativeTemplatePath = relativeWorkspaceToTemplatePath(
444
- relativeWorkspacePath,
445
- );
446
- return template.files.includes(relativeTemplatePath);
447
- },
448
- ).then((files) => files.map((f) => path.relative(workspace, f)));
439
+ // Find all the paths in the template that clash with an existing one in the
440
+ // workspace
441
+ const matchingRelativeWorkspacePaths = (
442
+ await Promise.all(
443
+ template.files.map(async (relativeTemplatePath) => {
444
+ const relativeWorkspacePath =
445
+ relativeTemplateToWorkspacePath(relativeTemplatePath);
446
+
447
+ const absoluteWorkspacePath = path.join(
448
+ workspace,
449
+ relativeWorkspacePath,
450
+ );
451
+
452
+ if (!(await exists(absoluteWorkspacePath))) {
453
+ return undefined;
454
+ }
455
+
456
+ // We ignore directories in this clash detection
457
+ if (await isDirectory(absoluteWorkspacePath)) {
458
+ return undefined;
459
+ }
460
+
461
+ return relativeWorkspacePath;
462
+ }),
463
+ )
464
+ ).filter((relativeWorkspacePath) => relativeWorkspacePath !== undefined);
465
+
466
+ const matchingRelativeWorkspacePathsSet = new Set(
467
+ matchingRelativeWorkspacePaths,
468
+ );
449
469
 
450
470
  // Ask the user for permission to overwrite existing files if needed
451
471
  if (matchingRelativeWorkspacePaths.length !== 0) {
@@ -461,7 +481,7 @@ export async function copyProjectFiles(
461
481
 
462
482
  if (
463
483
  force === false &&
464
- matchingRelativeWorkspacePaths.includes(relativeWorkspacePath)
484
+ matchingRelativeWorkspacePathsSet.has(relativeWorkspacePath)
465
485
  ) {
466
486
  continue;
467
487
  }
@@ -473,7 +493,7 @@ export async function copyProjectFiles(
473
493
  await copy(absoluteTemplatePath, absoluteWorkspacePath);
474
494
  }
475
495
 
476
- console.log(`✨ ${chalk.cyan(`Template files copied`)} ✨`);
496
+ console.log(`✨ ${styleText("cyan", `Template files copied`)} ✨`);
477
497
  }
478
498
 
479
499
  /**
@@ -549,16 +569,25 @@ export async function installProjectDependencies(
549
569
  console.log();
550
570
  console.log(commandString);
551
571
 
552
- await spawn(commandString, [], {
553
- cwd: workspace,
554
- // We need to run with `shell: true` for this to work on powershell, but
555
- // we already enclosed every dependency identifier in quotes, so this
556
- // is safe.
557
- shell: true,
558
- stdio: "inherit",
559
- });
560
-
561
- console.log(`✨ ${chalk.cyan(`Dependencies installed`)} ✨`);
572
+ try {
573
+ await spawn(commandString, [], {
574
+ cwd: workspace,
575
+ // We need to run with `shell: true` for this to work on powershell, but
576
+ // we already enclosed every dependency identifier in quotes, so this
577
+ // is safe.
578
+ shell: true,
579
+ stdio: "inherit",
580
+ });
581
+ } catch (error) {
582
+ ensureError(error);
583
+
584
+ throw new HardhatError(
585
+ HardhatError.ERRORS.CORE.INIT.FAILED_TO_INSTALL_DEPENDENCIES,
586
+ error,
587
+ );
588
+ }
589
+
590
+ console.log(`✨ ${styleText("cyan", `Dependencies installed`)} ✨`);
562
591
  }
563
592
  }
564
593
 
@@ -593,26 +622,40 @@ export async function installProjectDependencies(
593
622
  console.log();
594
623
  console.log(commandString);
595
624
 
596
- await spawn(commandString, [], {
597
- cwd: workspace,
598
- // We need to run with `shell: true` for this to work on powershell, but
599
- // we already enclosed every dependency identifier in quotes, so this
600
- // is safe.
601
- shell: true,
602
- stdio: "inherit",
603
- });
604
-
605
- console.log(`✨ ${chalk.cyan(`Dependencies updated`)} ✨`);
625
+ try {
626
+ await spawn(commandString, [], {
627
+ cwd: workspace,
628
+ // We need to run with `shell: true` for this to work on powershell, but
629
+ // we already enclosed every dependency identifier in quotes, so this
630
+ // is safe.
631
+ shell: true,
632
+ stdio: "inherit",
633
+ });
634
+ } catch (error) {
635
+ ensureError(error);
636
+
637
+ throw new HardhatError(
638
+ HardhatError.ERRORS.CORE.INIT.FAILED_TO_INSTALL_DEPENDENCIES,
639
+ error,
640
+ );
641
+ }
642
+
643
+ console.log(`✨ ${styleText("cyan", `Dependencies updated`)} ✨`);
606
644
  }
607
645
  }
608
646
  }
609
647
 
610
648
  function showStarOnGitHubMessage() {
611
649
  console.log(
612
- chalk.cyan("Give Hardhat a star on Github if you're enjoying it! ⭐️✨"),
650
+ styleText(
651
+ "cyan",
652
+ "Give Hardhat a star on GitHub if you're enjoying it! ⭐️✨",
653
+ ),
613
654
  );
614
655
  console.log();
615
- console.log(chalk.cyan(" https://github.com/NomicFoundation/hardhat"));
656
+ console.log(
657
+ styleText("cyan", " https://github.com/NomicFoundation/hardhat"),
658
+ );
616
659
  }
617
660
 
618
661
  // NOTE: This function is exported for testing purposes only.
@@ -1,6 +1,8 @@
1
+ import type { SemverVersion } from "@nomicfoundation/hardhat-utils/fast-semver";
2
+
1
3
  import { execSync } from "node:child_process";
2
4
 
3
- import semver from "semver";
5
+ import { parseVersion } from "@nomicfoundation/hardhat-utils/fast-semver";
4
6
 
5
7
  type PackageManager = "npm" | "yarn" | "pnpm" | "bun" | "deno";
6
8
 
@@ -156,7 +158,7 @@ export async function installsPeerDependenciesByDefault(
156
158
  config,
157
159
  );
158
160
  // If we couldn't retrieve the npm version, we assume it is higher than 7
159
- if (npmVersion === undefined || npmVersion.major >= 7) {
161
+ if (npmVersion === undefined || npmVersion[0] >= 7) {
160
162
  // If legacy-peer-deps hasn't been explicitly set to true,
161
163
  // peer dependencies are installed by default
162
164
  if (legacyPeerDeps !== "true") {
@@ -177,7 +179,7 @@ export async function installsPeerDependenciesByDefault(
177
179
  config,
178
180
  );
179
181
  // If we couldn't retrieve the pnpm version, we assume it is higher than 8
180
- if (pnpmVersion === undefined || pnpmVersion.major >= 8) {
182
+ if (pnpmVersion === undefined || pnpmVersion[0] >= 8) {
181
183
  // If auto-install-peers hasn't been explicitly set to false,
182
184
  // peer dependencies are installed by default
183
185
  if (autoInstallPeers !== "false") {
@@ -207,16 +209,16 @@ async function getVersion(
207
209
  workspace: string,
208
210
  packageManager: PackageManager,
209
211
  version?: string,
210
- ): Promise<semver.SemVer | undefined> {
212
+ ): Promise<SemverVersion | undefined> {
211
213
  if (version !== undefined) {
212
- return semver.parse(version) ?? undefined;
214
+ return parseVersion(version.trim());
213
215
  }
214
216
  try {
215
217
  const versionString = execSync(`${packageManager} --version`, {
216
218
  cwd: workspace,
217
219
  encoding: "utf8",
218
220
  });
219
- return semver.parse(versionString) ?? undefined;
221
+ return parseVersion(versionString.trim());
220
222
  } catch (_error) {
221
223
  return undefined;
222
224
  }
@@ -1,8 +1,9 @@
1
1
  import type { Template } from "./template.js";
2
2
 
3
+ import { styleText } from "node:util";
4
+
3
5
  import { HardhatError } from "@nomicfoundation/hardhat-errors";
4
6
  import { shortenPath } from "@nomicfoundation/hardhat-utils/path";
5
- import chalk from "chalk";
6
7
  import enquirer from "enquirer";
7
8
 
8
9
  export async function promptForHardhatVersion(): Promise<
@@ -116,7 +117,7 @@ export async function promptForInstall(
116
117
  {
117
118
  name: "install",
118
119
  type: "confirm",
119
- message: `You need to install the necessary dependencies using the following command:\n${chalk.italic(safelyFormattedCommand)}\n\nDo you want to run it now?`,
120
+ message: `You need to install the necessary dependencies using the following command:\n${styleText("italic", safelyFormattedCommand)}\n\nDo you want to run it now?`,
120
121
  initial: true,
121
122
  },
122
123
  ]);
@@ -133,7 +134,7 @@ export async function promptForUpdate(
133
134
  {
134
135
  name: "update",
135
136
  type: "confirm",
136
- message: `You need to update the following dependencies using the following command:\n${chalk.italic(safelyFormattedCommand)}\n\nDo you want to run it now?`,
137
+ message: `You need to update the following dependencies using the following command:\n${styleText("italic", safelyFormattedCommand)}\n\nDo you want to run it now?`,
137
138
  initial: true,
138
139
  },
139
140
  ]);
@@ -5,7 +5,7 @@ import {
5
5
  exists,
6
6
  getAllFilesMatching,
7
7
  isDirectory,
8
- readdir,
8
+ readdirOrEmpty,
9
9
  readJsonFile,
10
10
  } from "@nomicfoundation/hardhat-utils/fs";
11
11
  import {
@@ -40,11 +40,7 @@ export async function getTemplates(
40
40
  const packageRoot = await findClosestPackageRoot(import.meta.url);
41
41
  const pathToTemplates = path.join(packageRoot, "templates", templatesDir);
42
42
 
43
- if (!(await exists(pathToTemplates))) {
44
- return [];
45
- }
46
-
47
- const pathsToTemplates = await readdir(pathToTemplates);
43
+ const pathsToTemplates = await readdirOrEmpty(pathToTemplates);
48
44
  pathsToTemplates.sort();
49
45
 
50
46
  const templates = await Promise.all(
@@ -65,27 +61,26 @@ export async function getTemplates(
65
61
 
66
62
  const packageJson: PackageJson =
67
63
  await readJsonFile<PackageJson>(pathToPackageJson);
68
- const files = await getAllFilesMatching(pathToTemplate, (f) => {
69
- // Ignore the package.json file because it is handled separately
70
- if (f === pathToPackageJson) {
71
- return false;
72
- }
73
- // .gitignore files are expected to be called gitignore in the templates
74
- // because npm ignores .gitignore files during npm pack (see https://github.com/npm/npm/issues/3763)
75
- if (path.basename(f) === ".gitignore") {
76
- return false;
77
- }
78
- // We should ignore all the files according to the .gitignore rules
79
- // However, for simplicity, we just ignore the node_modules folder
80
- // If we needed to implement a more complex ignore logic, we could
81
- // use recently introduced glob from node:fs/promises
82
- if (
83
- path.relative(pathToTemplate, f).split(path.sep)[0] === "node_modules"
84
- ) {
85
- return false;
86
- }
87
- return true;
88
- }).then((fs) => fs.map((f) => path.relative(pathToTemplate, f)));
64
+
65
+ const matchingFiles = await getAllFilesMatching(
66
+ pathToTemplate,
67
+ (f) => {
68
+ // Ignore the package.json file because it is handled separately
69
+ if (f === pathToPackageJson) {
70
+ return false;
71
+ }
72
+
73
+ // .gitignore files are expected to be called gitignore in the templates
74
+ // because npm ignores .gitignore files during npm pack (see https://github.com/npm/npm/issues/3763)
75
+ if (path.basename(f) === ".gitignore") {
76
+ return false;
77
+ }
78
+ return true;
79
+ },
80
+ (dir) => path.basename(dir) !== "node_modules",
81
+ );
82
+
83
+ const files = matchingFiles.map((f) => path.relative(pathToTemplate, f));
89
84
 
90
85
  return {
91
86
  name,
@@ -4,6 +4,7 @@ import type {
4
4
  } from "../../types/global-options.js";
5
5
  import type { HardhatRuntimeEnvironment } from "../../types/hre.js";
6
6
  import type { Task, TaskArguments } from "../../types/tasks.js";
7
+ import type { DebugLogger } from "@nomicfoundation/hardhat-utils/debug";
7
8
 
8
9
  import { fileURLToPath } from "node:url";
9
10
 
@@ -12,6 +13,7 @@ import {
12
13
  assertHardhatInvariant,
13
14
  } from "@nomicfoundation/hardhat-errors";
14
15
  import { isCi } from "@nomicfoundation/hardhat-utils/ci";
16
+ import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
15
17
  import { ensureError } from "@nomicfoundation/hardhat-utils/error";
16
18
  import { getRealPath } from "@nomicfoundation/hardhat-utils/fs";
17
19
  import {
@@ -20,7 +22,6 @@ import {
20
22
  readClosestPackageJson,
21
23
  } from "@nomicfoundation/hardhat-utils/package";
22
24
  import { kebabToCamelCase } from "@nomicfoundation/hardhat-utils/string";
23
- import debug from "debug";
24
25
  import { register } from "tsx/esm/api";
25
26
 
26
27
  import {
@@ -69,7 +70,7 @@ export async function main(
69
70
 
70
71
  const print = options.print ?? console.log;
71
72
 
72
- const log = debug("hardhat:core:cli:main");
73
+ const log = createDebug("hardhat:core:cli:main");
73
74
 
74
75
  let builtinGlobalOptions;
75
76
  let configPath;
@@ -752,7 +753,7 @@ npm pkg set type="module"
752
753
  */
753
754
  async function isHardhatInstalledLocallyOrLinked(
754
755
  configPath: string,
755
- log: debug.Debugger,
756
+ log: DebugLogger,
756
757
  ) {
757
758
  try {
758
759
  // Based on Node.js resolution algorithm find the real path
@@ -2,11 +2,15 @@
2
2
  // is always run during the initialization of the CLI.
3
3
  //
4
4
  // NOTE: This file shouldn't import any non-builtin dependency, as it's imported
5
- // before enabling source maps support. TODO: Change chalk to util.styleText
5
+ // before enabling source maps support.
6
+ //
7
+ // EXCEPTION: we share `getRuntimeInfo` with the rest of the codebase instead
8
+ // of duplicating it. The helper has no transitive dependencies, so the risk of
9
+ // an unreadable stack trace from its import graph is negligible.
6
10
 
7
- import chalk from "chalk";
11
+ import { getRuntimeInfo } from "@nomicfoundation/hardhat-utils/runtime";
8
12
 
9
- export const MIN_SUPPORTED_NODE_VERSION: number[] = [22, 10, 0];
13
+ export const MIN_SUPPORTED_NODE_VERSION: number[] = [22, 13, 0];
10
14
 
11
15
  export function isNodeVersionSupported(): boolean {
12
16
  try {
@@ -15,10 +19,6 @@ export function isNodeVersionSupported(): boolean {
15
19
  const minor = parseInt(minorStr, 10);
16
20
  const patch = parseInt(patchStr, 10);
17
21
 
18
- if (major % 2 === 1) {
19
- return false;
20
- }
21
-
22
22
  if (major < MIN_SUPPORTED_NODE_VERSION[0]) {
23
23
  return false;
24
24
  } else if (major > MIN_SUPPORTED_NODE_VERSION[0]) {
@@ -42,12 +42,20 @@ export function isNodeVersionSupported(): boolean {
42
42
  return true;
43
43
  }
44
44
 
45
- export function printNodeJsVersionWarningIfNecessary(): void {
45
+ export function exitIfNodeVersionNotSupported(): void {
46
+ // Only enforce the Node.js version when we're actually running on Node.js.
47
+ // Bun and Deno emulate `process.versions.node`, so checking it there would
48
+ // incorrectly reject users on those runtimes.
49
+ if (getRuntimeInfo()?.runtime !== "node") {
50
+ return;
51
+ }
52
+
46
53
  if (!isNodeVersionSupported()) {
47
- console.log(
48
- chalk.bold(`\n${chalk.yellow("WARNING:")} You are using Node.js ${process.versions.node} which is not supported by Hardhat.
49
- Please upgrade to ${MIN_SUPPORTED_NODE_VERSION.join(".")} or a later LTS version (even major version number)\n`),
54
+ console.error(
55
+ `\nERROR: You are using Node.js ${process.versions.node} which is not supported by Hardhat.\n` +
56
+ `Please upgrade to Node.js ${MIN_SUPPORTED_NODE_VERSION.join(".")} or later.\n`,
50
57
  );
51
- return;
58
+
59
+ process.exit(1);
52
60
  }
53
61
  }
@@ -6,8 +6,8 @@ import type {
6
6
 
7
7
  import os from "node:os";
8
8
 
9
+ import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
9
10
  import { spawnDetachedSubProcess } from "@nomicfoundation/hardhat-utils/subprocess";
10
- import debug from "debug";
11
11
 
12
12
  import { getHardhatVersion } from "../../../utils/package.js";
13
13
  import {
@@ -17,7 +17,7 @@ import {
17
17
 
18
18
  import { getAnalyticsClientId } from "./utils.js";
19
19
 
20
- const log = debug("hardhat:cli:telemetry:analytics");
20
+ const log = createDebug("hardhat:core:cli:telemetry:analytics");
21
21
 
22
22
  const SESSION_ID = Math.random().toString();
23
23
  const ENGAGEMENT_TIME_MSEC = "10000";
@@ -2,15 +2,15 @@ import type { AnalyticsFile } from "./types.js";
2
2
 
3
3
  import path from "node:path";
4
4
 
5
+ import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
5
6
  import {
6
7
  exists,
7
8
  readJsonFile,
8
9
  writeJsonFile,
9
10
  } from "@nomicfoundation/hardhat-utils/fs";
10
11
  import { getTelemetryDir } from "@nomicfoundation/hardhat-utils/global-dir";
11
- import debug from "debug";
12
12
 
13
- const log = debug("hardhat:cli:telemetry:analytics:utils");
13
+ const log = createDebug("hardhat:core:cli:telemetry:analytics:utils");
14
14
 
15
15
  const ANALYTICS_FILE_NAME = "analytics.json";
16
16
 
@@ -1,9 +1,9 @@
1
+ import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
1
2
  import { isObject } from "@nomicfoundation/hardhat-utils/lang";
2
- import debug from "debug";
3
3
 
4
4
  import { sendErrorTelemetry } from "./reporter.js";
5
5
 
6
- const log = debug("hardhat:core:telemetry:global-error-handlers");
6
+ const log = createDebug("hardhat:core:cli:telemetry:global-error-handlers");
7
7
 
8
8
  function createUnhandledErrorListener(isPromiseRejection: boolean) {
9
9
  const description = isPromiseRejection
@@ -2,7 +2,7 @@ import {
2
2
  HardhatError,
3
3
  HardhatPluginError,
4
4
  } from "@nomicfoundation/hardhat-errors";
5
- import debug from "debug";
5
+ import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
6
6
 
7
7
  import {
8
8
  ProviderError,
@@ -12,7 +12,7 @@ import { UsingHardhat2PluginError } from "../../../using-hardhat2-plugin-errors.
12
12
  import { getHardhatVersion } from "../../../utils/package.js";
13
13
  import { isTelemetryAllowed } from "../telemetry-permissions.js";
14
14
 
15
- const log = debug("hardhat:cli:telemetry:sentry:reporter");
15
+ const log = createDebug("hardhat:core:cli:telemetry:sentry:reporter");
16
16
 
17
17
  // export const SENTRY_DSN =
18
18
  // "https://d578a176729662a28e7a8da268d36912@o385026.ingest.us.sentry.io/4507685793103872"; // DEV
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-restricted-syntax -- Allow top-level await */
2
+ import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
2
3
  import { captureMessage, close, captureException } from "@sentry/core";
3
- import debug from "debug";
4
4
 
5
5
  import { Anonymizer } from "./anonymizer.js";
6
6
  import { init } from "./init.js";
@@ -9,7 +9,7 @@ import {
9
9
  sendEnvelopeToSentryBackend,
10
10
  } from "./transport.js";
11
11
 
12
- const log = debug("hardhat:core:sentry:subprocess");
12
+ const log = createDebug("hardhat:core:cli:telemetry:sentry:subprocess");
13
13
 
14
14
  const serializedEnvelope = process.argv[2];
15
15
  const configPath = process.argv[3] !== "" ? process.argv[3] : undefined;
@@ -7,10 +7,10 @@ import type {
7
7
  import { spawn } from "node:child_process";
8
8
  import { fileURLToPath } from "node:url";
9
9
 
10
+ import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
10
11
  import { createTransport, serializeEnvelope } from "@sentry/core";
11
- import debug from "debug";
12
12
 
13
- const log = debug("hardhat:core:sentry:transport");
13
+ const log = createDebug("hardhat:core:cli:telemetry:sentry:transport");
14
14
 
15
15
  /**
16
16
  * Creates a detached process transport.
@@ -1,17 +1,17 @@
1
1
  import path from "node:path";
2
2
 
3
3
  import { isCi } from "@nomicfoundation/hardhat-utils/ci";
4
+ import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
4
5
  import {
5
6
  exists,
6
7
  readJsonFile,
7
8
  writeJsonFile,
8
9
  } from "@nomicfoundation/hardhat-utils/fs";
9
10
  import { getTelemetryDir } from "@nomicfoundation/hardhat-utils/global-dir";
10
- import debug from "debug";
11
11
 
12
12
  import { sendTelemetryConfigAnalytics } from "./analytics/analytics.js";
13
13
 
14
- const log = debug("hardhat:cli:telemetry:telemetry-permissions");
14
+ const log = createDebug("hardhat:core:cli:telemetry:permissions");
15
15
 
16
16
  interface TelemetryConfig {
17
17
  enabled: boolean;