hardhat 3.4.2 → 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.
- package/CHANGELOG.md +29 -0
- package/dist/src/internal/builtin-plugins/console/task-action.js +4 -4
- package/dist/src/internal/builtin-plugins/console/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/coverage-manager.js +7 -7
- package/dist/src/internal/builtin-plugins/coverage/coverage-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/helpers/accessors.js +1 -1
- package/dist/src/internal/builtin-plugins/coverage/helpers/accessors.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js +2 -2
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/instrumentation.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/instrumentation.js +7 -2
- package/dist/src/internal/builtin-plugins/coverage/instrumentation.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/process-coverage.js +6 -6
- package/dist/src/internal/builtin-plugins/coverage/process-coverage.js.map +1 -1
- package/dist/src/internal/builtin-plugins/flatten/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/flatten/task-action.js +4 -4
- package/dist/src/internal/builtin-plugins/flatten/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.js +10 -10
- package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.js +12 -9
- package/dist/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/accessors.js +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/accessors.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/utils.js +2 -2
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/utils.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.js +9 -9
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.js +5 -5
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js +2 -2
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.d.ts +2 -2
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.js +21 -24
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.js +13 -11
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.js.map +1 -1
- package/dist/src/internal/builtin-plugins/node/artifacts/build-info-watcher.js +2 -2
- package/dist/src/internal/builtin-plugins/node/artifacts/build-info-watcher.js.map +1 -1
- package/dist/src/internal/builtin-plugins/node/helpers.d.ts +2 -1
- package/dist/src/internal/builtin-plugins/node/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/node/helpers.js +3 -3
- package/dist/src/internal/builtin-plugins/node/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/node/json-rpc/server.js +2 -2
- package/dist/src/internal/builtin-plugins/node/json-rpc/server.js.map +1 -1
- package/dist/src/internal/builtin-plugins/node/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/node/task-action.js +4 -4
- package/dist/src/internal/builtin-plugins/node/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js +18 -9
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.d.ts +8 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.js +46 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.js +9 -3
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.js +2 -2
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/index.js +2 -2
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-wrapper.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-wrapper.js +7 -19
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-wrapper.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.js +4 -3
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/utils.d.ts +2 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/utils.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/utils.js +12 -8
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/utils.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-info.d.ts +3 -2
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-info.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-info.js +15 -6
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-info.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/config.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/config.js +2 -2
- package/dist/src/internal/builtin-plugins/solidity/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/constants.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/solidity/constants.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/constants.js +2 -0
- package/dist/src/internal/builtin-plugins/solidity/constants.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/config.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/config.js +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts +1 -2
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.js +3 -3
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.d.ts +2 -2
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.js +19 -17
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.js +5 -2
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/test/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/test/task-action.js +8 -6
- package/dist/src/internal/builtin-plugins/test/task-action.js.map +1 -1
- package/dist/src/internal/cli/banner-manager.js +2 -2
- package/dist/src/internal/cli/banner-manager.js.map +1 -1
- package/dist/src/internal/cli/error-handler.d.ts.map +1 -1
- package/dist/src/internal/cli/error-handler.js +6 -6
- package/dist/src/internal/cli/error-handler.js.map +1 -1
- package/dist/src/internal/cli/help/get-help-string.js +2 -2
- package/dist/src/internal/cli/help/get-help-string.js.map +1 -1
- package/dist/src/internal/cli/init/init.d.ts.map +1 -1
- package/dist/src/internal/cli/init/init.js +40 -28
- package/dist/src/internal/cli/init/init.js.map +1 -1
- package/dist/src/internal/cli/init/package-manager.d.ts.map +1 -1
- package/dist/src/internal/cli/init/package-manager.js +5 -5
- package/dist/src/internal/cli/init/package-manager.js.map +1 -1
- package/dist/src/internal/cli/init/prompt.d.ts.map +1 -1
- package/dist/src/internal/cli/init/prompt.js +3 -3
- package/dist/src/internal/cli/init/prompt.js.map +1 -1
- package/dist/src/internal/cli/main.d.ts.map +1 -1
- package/dist/src/internal/cli/main.js +2 -2
- package/dist/src/internal/cli/main.js.map +1 -1
- package/dist/src/internal/cli/node-version.js +1 -1
- package/dist/src/internal/cli/telemetry/analytics/analytics.js +2 -2
- package/dist/src/internal/cli/telemetry/analytics/analytics.js.map +1 -1
- package/dist/src/internal/cli/telemetry/analytics/utils.js +2 -2
- package/dist/src/internal/cli/telemetry/analytics/utils.js.map +1 -1
- package/dist/src/internal/cli/telemetry/error-reporter/global-error-handlers.js +2 -2
- package/dist/src/internal/cli/telemetry/error-reporter/global-error-handlers.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/reporter.js +2 -2
- package/dist/src/internal/cli/telemetry/sentry/reporter.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/subprocess.js +2 -2
- package/dist/src/internal/cli/telemetry/sentry/subprocess.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/transport.js +2 -2
- package/dist/src/internal/cli/telemetry/sentry/transport.js.map +1 -1
- package/dist/src/internal/cli/telemetry/telemetry-permissions.js +2 -2
- package/dist/src/internal/cli/telemetry/telemetry-permissions.js.map +1 -1
- package/dist/src/internal/config-loading.js +2 -2
- package/dist/src/internal/config-loading.js.map +1 -1
- package/dist/src/internal/core/hook-manager.d.ts.map +1 -1
- package/dist/src/internal/core/hook-manager.js +10 -3
- package/dist/src/internal/core/hook-manager.js.map +1 -1
- package/dist/src/internal/core/user-interruptions.js +4 -4
- package/dist/src/internal/core/user-interruptions.js.map +1 -1
- package/dist/src/internal/using-hardhat2-plugin-errors.d.ts.map +1 -1
- package/dist/src/internal/using-hardhat2-plugin-errors.js +2 -2
- package/dist/src/internal/using-hardhat2-plugin-errors.js.map +1 -1
- package/package.json +6 -9
- package/src/internal/builtin-plugins/console/task-action.ts +4 -4
- package/src/internal/builtin-plugins/coverage/coverage-manager.ts +7 -7
- package/src/internal/builtin-plugins/coverage/helpers/accessors.ts +1 -1
- package/src/internal/builtin-plugins/coverage/hook-handlers/solidity.ts +2 -2
- package/src/internal/builtin-plugins/coverage/instrumentation.ts +21 -2
- package/src/internal/builtin-plugins/coverage/process-coverage.ts +6 -6
- package/src/internal/builtin-plugins/flatten/task-action.ts +8 -4
- package/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.ts +11 -10
- package/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.ts +13 -9
- package/src/internal/builtin-plugins/gas-analytics/helpers/accessors.ts +1 -1
- package/src/internal/builtin-plugins/gas-analytics/helpers/utils.ts +2 -2
- package/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.ts +10 -9
- package/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.ts +11 -5
- package/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts +2 -2
- package/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.ts +23 -23
- package/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.ts +14 -11
- package/src/internal/builtin-plugins/node/artifacts/build-info-watcher.ts +2 -2
- package/src/internal/builtin-plugins/node/helpers.ts +7 -4
- package/src/internal/builtin-plugins/node/json-rpc/server.ts +2 -2
- package/src/internal/builtin-plugins/node/task-action.ts +5 -4
- package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +23 -9
- package/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.ts +61 -0
- package/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.ts +17 -3
- package/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts +4 -2
- package/src/internal/builtin-plugins/solidity/build-system/compiler/index.ts +2 -2
- package/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-wrapper.ts +19 -22
- package/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.ts +9 -1
- package/src/internal/builtin-plugins/solidity/build-system/resolver/utils.ts +16 -7
- package/src/internal/builtin-plugins/solidity/build-system/solc-info.ts +27 -6
- package/src/internal/builtin-plugins/solidity/config.ts +5 -2
- package/src/internal/builtin-plugins/solidity/constants.ts +3 -0
- package/src/internal/builtin-plugins/solidity-test/config.ts +1 -0
- package/src/internal/builtin-plugins/solidity-test/helpers.ts +3 -4
- package/src/internal/builtin-plugins/solidity-test/reporter.ts +19 -18
- package/src/internal/builtin-plugins/solidity-test/task-action.ts +5 -2
- package/src/internal/builtin-plugins/solidity-test/type-extensions.ts +1 -0
- package/src/internal/builtin-plugins/test/task-action.ts +12 -6
- package/src/internal/cli/banner-manager.ts +2 -2
- package/src/internal/cli/error-handler.ts +10 -6
- package/src/internal/cli/help/get-help-string.ts +2 -2
- package/src/internal/cli/init/init.ts +53 -28
- package/src/internal/cli/init/package-manager.ts +8 -6
- package/src/internal/cli/init/prompt.ts +4 -3
- package/src/internal/cli/main.ts +4 -3
- package/src/internal/cli/node-version.ts +1 -1
- package/src/internal/cli/telemetry/analytics/analytics.ts +2 -2
- package/src/internal/cli/telemetry/analytics/utils.ts +2 -2
- package/src/internal/cli/telemetry/error-reporter/global-error-handlers.ts +2 -2
- package/src/internal/cli/telemetry/sentry/reporter.ts +2 -2
- package/src/internal/cli/telemetry/sentry/subprocess.ts +2 -2
- package/src/internal/cli/telemetry/sentry/transport.ts +2 -2
- package/src/internal/cli/telemetry/telemetry-permissions.ts +2 -2
- package/src/internal/config-loading.ts +2 -2
- package/src/internal/core/hook-manager.ts +21 -3
- package/src/internal/core/user-interruptions.ts +4 -4
- package/src/internal/using-hardhat2-plugin-errors.ts +2 -2
- package/templates/hardhat-3/01-node-test-runner-viem/package.json +6 -6
- package/templates/hardhat-3/02-mocha-ethers/package.json +12 -12
- package/templates/hardhat-3/03-minimal/package.json +1 -1
- package/dist/src/internal/utils/colorizer.d.ts +0 -10
- package/dist/src/internal/utils/colorizer.d.ts.map +0 -1
- package/dist/src/internal/utils/colorizer.js +0 -2
- package/dist/src/internal/utils/colorizer.js.map +0 -1
- package/src/internal/utils/colorizer.ts +0 -9
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Abi } from "../../../types/artifacts.js";
|
|
2
2
|
import type { ChainType } from "../../../types/network.js";
|
|
3
3
|
import type { SolidityTestConfig } from "../../../types/test.js";
|
|
4
|
-
import type { Colorizer } from "../../utils/colorizer.js";
|
|
5
4
|
import type {
|
|
6
5
|
SolidityTestRunnerConfigArgs,
|
|
7
6
|
PathPermission,
|
|
@@ -10,6 +9,8 @@ import type {
|
|
|
10
9
|
TestFunctionOverride,
|
|
11
10
|
} from "@nomicfoundation/edr";
|
|
12
11
|
|
|
12
|
+
import { styleText } from "node:util";
|
|
13
|
+
|
|
13
14
|
import {
|
|
14
15
|
opGenesisState,
|
|
15
16
|
l1GenesisState,
|
|
@@ -19,7 +20,6 @@ import {
|
|
|
19
20
|
l1HardforkFromString,
|
|
20
21
|
} from "@nomicfoundation/edr";
|
|
21
22
|
import { hexStringToBytes } from "@nomicfoundation/hardhat-utils/hex";
|
|
22
|
-
import chalk from "chalk";
|
|
23
23
|
|
|
24
24
|
import { DEFAULT_VERBOSITY, OPTIMISM_CHAIN_TYPE } from "../../constants.js";
|
|
25
25
|
import { resolveHardfork } from "../network-manager/config-resolution.js";
|
|
@@ -161,7 +161,6 @@ export function isTestSuiteArtifact(artifact: Artifact): boolean {
|
|
|
161
161
|
export function warnDeprecatedTestFail(
|
|
162
162
|
artifact: Artifact,
|
|
163
163
|
sourceNameToUserSourceName: Map<string, string>,
|
|
164
|
-
colorizer: Colorizer = chalk,
|
|
165
164
|
): void {
|
|
166
165
|
const abi: Abi = JSON.parse(artifact.contract.abi);
|
|
167
166
|
|
|
@@ -175,7 +174,7 @@ export function warnDeprecatedTestFail(
|
|
|
175
174
|
artifact.id,
|
|
176
175
|
sourceNameToUserSourceName,
|
|
177
176
|
);
|
|
178
|
-
const warningMessage = `${
|
|
177
|
+
const warningMessage = `${styleText("yellow", "Warning")}: ${name} The support for the prefix \`testFail*\` has been removed. Consider using \`vm.expectRevert()\` for testing reverts in ${formattedLocation}\n`;
|
|
179
178
|
|
|
180
179
|
console.warn(warningMessage);
|
|
181
180
|
}
|
|
@@ -3,11 +3,11 @@ import type {
|
|
|
3
3
|
TestReporterResult,
|
|
4
4
|
TestStatus,
|
|
5
5
|
} from "./types.js";
|
|
6
|
-
import type { Colorizer } from "../../utils/colorizer.js";
|
|
7
6
|
import type { TestResult } from "@nomicfoundation/edr";
|
|
8
7
|
|
|
8
|
+
import { styleText } from "node:util";
|
|
9
|
+
|
|
9
10
|
import { bytesToHexString } from "@nomicfoundation/hardhat-utils/hex";
|
|
10
|
-
import chalk from "chalk";
|
|
11
11
|
|
|
12
12
|
import { sendErrorTelemetry } from "../../cli/telemetry/error-reporter/reporter.js";
|
|
13
13
|
import { SolidityTestStackTraceGenerationError } from "../network-manager/edr/stack-traces/stack-trace-generation-errors.js";
|
|
@@ -55,7 +55,8 @@ export async function* testReporter(
|
|
|
55
55
|
sourceNameToUserSourceName: Map<string, string>,
|
|
56
56
|
verbosity: number,
|
|
57
57
|
testSummaryIndex: number = 0,
|
|
58
|
-
|
|
58
|
+
// Allow passing a custom colorize function for testing purposes
|
|
59
|
+
colorize: typeof styleText = styleText,
|
|
59
60
|
): TestReporterResult {
|
|
60
61
|
let runSuccessCount = 0;
|
|
61
62
|
let runFailureCount = testSummaryIndex === 0 ? 1 : testSummaryIndex;
|
|
@@ -97,7 +98,7 @@ export async function* testReporter(
|
|
|
97
98
|
if (suiteResult.warnings.length > 0) {
|
|
98
99
|
indenter.inc();
|
|
99
100
|
for (const warning of suiteResult.warnings) {
|
|
100
|
-
yield indenter.t`${
|
|
101
|
+
yield indenter.t`${colorize("yellow", "Warning")}${colorize("grey", `: ${warning}`)}\n`;
|
|
101
102
|
}
|
|
102
103
|
indenter.dec();
|
|
103
104
|
yield "\n";
|
|
@@ -137,9 +138,9 @@ export async function* testReporter(
|
|
|
137
138
|
|
|
138
139
|
switch (status) {
|
|
139
140
|
case "Success": {
|
|
140
|
-
let successOutput = `${
|
|
141
|
+
let successOutput = `${colorize("green", "✔")} ${colorize("grey", name)}`;
|
|
141
142
|
if (details !== "") {
|
|
142
|
-
successOutput +=
|
|
143
|
+
successOutput += colorize("dim", details);
|
|
143
144
|
}
|
|
144
145
|
yield indenter.t`${successOutput}\n`;
|
|
145
146
|
suiteSuccessCount++;
|
|
@@ -153,7 +154,7 @@ export async function* testReporter(
|
|
|
153
154
|
}
|
|
154
155
|
case "Failure": {
|
|
155
156
|
failures.push({ testResult, contractName: suiteResult.id.name });
|
|
156
|
-
yield indenter.t`${
|
|
157
|
+
yield indenter.t`${colorize("red", `${runFailureCount}) ${name}`)}\n`;
|
|
157
158
|
runFailureCount++;
|
|
158
159
|
if (verbosity >= 3) {
|
|
159
160
|
printExecutionTraces = true;
|
|
@@ -164,7 +165,7 @@ export async function* testReporter(
|
|
|
164
165
|
break;
|
|
165
166
|
}
|
|
166
167
|
case "Skipped": {
|
|
167
|
-
yield indenter.t`${
|
|
168
|
+
yield indenter.t`${colorize("cyan", `- ${name}`)}\n`;
|
|
168
169
|
suiteSkippedCount++;
|
|
169
170
|
break;
|
|
170
171
|
}
|
|
@@ -194,7 +195,7 @@ export async function* testReporter(
|
|
|
194
195
|
indenter.inc();
|
|
195
196
|
yield indenter.t`Call Traces:\n`;
|
|
196
197
|
indenter.inc();
|
|
197
|
-
yield `${formatTraces(callTraces, indenter.prefix(),
|
|
198
|
+
yield `${formatTraces(callTraces, indenter.prefix(), colorize)}\n`;
|
|
198
199
|
indenter.dec();
|
|
199
200
|
indenter.dec();
|
|
200
201
|
if (testIndex < suiteResult.testResults.length - 1) {
|
|
@@ -226,12 +227,12 @@ export async function* testReporter(
|
|
|
226
227
|
yield "\n";
|
|
227
228
|
yield "\n";
|
|
228
229
|
|
|
229
|
-
yield indenter.t`${
|
|
230
|
+
yield indenter.t`${colorize("green", `${runSuccessCount} passing`)}\n`;
|
|
230
231
|
if (failures.length > 0) {
|
|
231
|
-
yield indenter.t`${
|
|
232
|
+
yield indenter.t`${colorize("red", `${failures.length} failing`)}\n`;
|
|
232
233
|
}
|
|
233
234
|
if (runSkippedCount > 0) {
|
|
234
|
-
yield indenter.t`${
|
|
235
|
+
yield indenter.t`${colorize("cyan", `${runSkippedCount} skipped`)}\n`;
|
|
235
236
|
}
|
|
236
237
|
}
|
|
237
238
|
|
|
@@ -273,7 +274,7 @@ export async function* testReporter(
|
|
|
273
274
|
? "FFI is disabled; set `test.solidity.ffi` to `true` in your Hardhat config to allow tests to call external commands"
|
|
274
275
|
: failure.reason ?? "Unknown error";
|
|
275
276
|
}
|
|
276
|
-
yield* output(indenter.t`${
|
|
277
|
+
yield* output(indenter.t`${colorize("red", `Error: ${reason}`)}\n`);
|
|
277
278
|
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- Ignore Cases not matched: undefined
|
|
278
279
|
switch (stackTrace?.kind) {
|
|
279
280
|
case "StackTrace":
|
|
@@ -287,7 +288,7 @@ export async function* testReporter(
|
|
|
287
288
|
}
|
|
288
289
|
}
|
|
289
290
|
if (stackTraceStack.length > 0) {
|
|
290
|
-
yield* output(`${
|
|
291
|
+
yield* output(`${colorize("grey", stackTraceStack.join("\n"))}\n`);
|
|
291
292
|
}
|
|
292
293
|
yield* output("\n");
|
|
293
294
|
break;
|
|
@@ -296,13 +297,13 @@ export async function* testReporter(
|
|
|
296
297
|
new SolidityTestStackTraceGenerationError(stackTrace.errorMessage),
|
|
297
298
|
);
|
|
298
299
|
yield* output(
|
|
299
|
-
indenter.t`Stack Trace Warning: ${
|
|
300
|
+
indenter.t`Stack Trace Warning: ${colorize("grey", stackTrace.errorMessage)}\n`,
|
|
300
301
|
);
|
|
301
302
|
break;
|
|
302
303
|
case "UnsafeToReplay":
|
|
303
304
|
if (stackTrace.globalForkLatest === true) {
|
|
304
305
|
yield* output(
|
|
305
|
-
indenter.t`Stack Trace Warning: ${
|
|
306
|
+
indenter.t`Stack Trace Warning: ${colorize("grey", "The test is not safe to replay because a fork url without a fork block number was provided.")}\n`,
|
|
306
307
|
);
|
|
307
308
|
yield* output(
|
|
308
309
|
indenter.t`Try rerunning your tests with -vvv or above.\n`,
|
|
@@ -310,7 +311,7 @@ export async function* testReporter(
|
|
|
310
311
|
}
|
|
311
312
|
if (stackTrace.impureCheatcodes.length > 0) {
|
|
312
313
|
yield* output(
|
|
313
|
-
indenter.t`Stack Trace Warning: ${
|
|
314
|
+
indenter.t`Stack Trace Warning: ${colorize("grey", `The test is not safe to replay because it uses impure cheatcodes: ${stackTrace.impureCheatcodes.join(", ")}`)}\n`,
|
|
314
315
|
);
|
|
315
316
|
yield* output(
|
|
316
317
|
indenter.t`Try rerunning your tests with -vvv or above.\n`,
|
|
@@ -335,7 +336,7 @@ export async function* testReporter(
|
|
|
335
336
|
for (const [key, value] of Object.entries(counterexample)) {
|
|
336
337
|
const counterExampleDetails = `${key}: ${Buffer.isBuffer(value) ? bytesToHexString(value) : value}`;
|
|
337
338
|
yield* output(
|
|
338
|
-
indenter.t`${
|
|
339
|
+
indenter.t`${colorize("grey", counterExampleDetails)}\n`,
|
|
339
340
|
);
|
|
340
341
|
}
|
|
341
342
|
indenter.dec();
|
|
@@ -141,8 +141,11 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
141
141
|
({ edrArtifactsWithMetadata, allBuildInfosAndOutputs } =
|
|
142
142
|
await loadArtifacts(hre.solidity, ["contracts"]));
|
|
143
143
|
|
|
144
|
-
// When noCompile, validate
|
|
145
|
-
|
|
144
|
+
// When noCompile is enabled, only validate compiled artifacts for test roots
|
|
145
|
+
// explicitly selected by the user. If no files were specified, skip
|
|
146
|
+
// validating every discovered test root and run whatever compiled test
|
|
147
|
+
// suites are available.
|
|
148
|
+
if (noCompile === true && testFiles.length > 0) {
|
|
146
149
|
const compiledSources = new Set(
|
|
147
150
|
edrArtifactsWithMetadata.map(({ userSourceName }) =>
|
|
148
151
|
resolveFromRoot(hre.config.paths.root, userSourceName),
|
|
@@ -7,9 +7,10 @@ import type {
|
|
|
7
7
|
import type { TestSummary } from "../../../types/test.js";
|
|
8
8
|
import type { Result } from "../../../types/utils.js";
|
|
9
9
|
|
|
10
|
+
import { styleText } from "node:util";
|
|
11
|
+
|
|
10
12
|
import { HardhatError } from "@nomicfoundation/hardhat-errors";
|
|
11
13
|
import { isObject } from "@nomicfoundation/hardhat-utils/lang";
|
|
12
|
-
import chalk, { type ChalkInstance } from "chalk";
|
|
13
14
|
|
|
14
15
|
import {
|
|
15
16
|
errorResult,
|
|
@@ -194,19 +195,23 @@ const runAllTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
194
195
|
}
|
|
195
196
|
|
|
196
197
|
if (passed.length > 0) {
|
|
197
|
-
logSummaryLine("passing", passed,
|
|
198
|
+
logSummaryLine("passing", passed, (text: string) =>
|
|
199
|
+
styleText("green", text),
|
|
200
|
+
);
|
|
198
201
|
}
|
|
199
202
|
|
|
200
203
|
if (failed.length > 0) {
|
|
201
|
-
logSummaryLine("failing", failed,
|
|
204
|
+
logSummaryLine("failing", failed, (text: string) => styleText("red", text));
|
|
202
205
|
}
|
|
203
206
|
|
|
204
207
|
if (skipped.length > 0) {
|
|
205
|
-
logSummaryLine("skipped", skipped,
|
|
208
|
+
logSummaryLine("skipped", skipped, (text: string) =>
|
|
209
|
+
styleText("cyan", text),
|
|
210
|
+
);
|
|
206
211
|
}
|
|
207
212
|
|
|
208
213
|
if (todo.length > 0) {
|
|
209
|
-
logSummaryLine("todo", todo,
|
|
214
|
+
logSummaryLine("todo", todo, (text: string) => styleText("blue", text));
|
|
210
215
|
}
|
|
211
216
|
|
|
212
217
|
if (outputLines.length > 0) {
|
|
@@ -262,7 +267,8 @@ const runAllTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
262
267
|
function logSummaryLine(
|
|
263
268
|
label: string,
|
|
264
269
|
items: Array<[string, number]>,
|
|
265
|
-
|
|
270
|
+
// Allow passing a custom colorize function for testing purposes
|
|
271
|
+
color: (text: string) => string = (text) => styleText("white", text),
|
|
266
272
|
): void {
|
|
267
273
|
let total = 0;
|
|
268
274
|
const str = items
|
|
@@ -2,6 +2,7 @@ import type { Dispatcher } from "@nomicfoundation/hardhat-utils/request";
|
|
|
2
2
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
5
|
+
import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
|
|
5
6
|
import {
|
|
6
7
|
readJsonFile,
|
|
7
8
|
writeJsonFile,
|
|
@@ -10,9 +11,8 @@ import {
|
|
|
10
11
|
import { getCacheDir } from "@nomicfoundation/hardhat-utils/global-dir";
|
|
11
12
|
import { isObject } from "@nomicfoundation/hardhat-utils/lang";
|
|
12
13
|
import { getRequest } from "@nomicfoundation/hardhat-utils/request";
|
|
13
|
-
import debug from "debug";
|
|
14
14
|
|
|
15
|
-
const log =
|
|
15
|
+
const log = createDebug("hardhat:core:cli:banner-manager");
|
|
16
16
|
|
|
17
17
|
interface BannerConfig {
|
|
18
18
|
enabled: boolean;
|
|
@@ -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: `${
|
|
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: `${
|
|
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: `${
|
|
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:
|
|
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(
|
|
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
|
|
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 = `${
|
|
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,11 +2,13 @@ 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,
|
|
@@ -18,8 +20,6 @@ import {
|
|
|
18
20
|
writeJsonFile,
|
|
19
21
|
} from "@nomicfoundation/hardhat-utils/fs";
|
|
20
22
|
import { resolveFromRoot } from "@nomicfoundation/hardhat-utils/path";
|
|
21
|
-
import chalk from "chalk";
|
|
22
|
-
import debug from "debug";
|
|
23
23
|
import * as semver from "semver";
|
|
24
24
|
|
|
25
25
|
import { findClosestHardhatConfig } from "../../config-loading.js";
|
|
@@ -58,7 +58,7 @@ export interface InitHardhatOptions {
|
|
|
58
58
|
install?: boolean;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
const log =
|
|
61
|
+
const log = createDebug("hardhat:core:cli:init");
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* initHardhat implements the project initialization wizard flow.
|
|
@@ -165,7 +165,7 @@ function printAsciiLogo() {
|
|
|
165
165
|
// logo doesn't fit
|
|
166
166
|
process.stdout.write("\x1b[?7l");
|
|
167
167
|
|
|
168
|
-
console.log(
|
|
168
|
+
console.log(styleText("blue", logoLines));
|
|
169
169
|
|
|
170
170
|
// Re-enable auto-wapping
|
|
171
171
|
process.stdout.write("\x1b[?7h");
|
|
@@ -176,7 +176,7 @@ export async function printWelcomeMessage(): Promise<void> {
|
|
|
176
176
|
const hardhatVersion = await getHardhatVersion();
|
|
177
177
|
|
|
178
178
|
console.log(
|
|
179
|
-
|
|
179
|
+
styleText("cyan", `👷 Welcome to ${HARDHAT_NAME} v${hardhatVersion} 👷\n`),
|
|
180
180
|
);
|
|
181
181
|
|
|
182
182
|
// Warn the user if they are using an outdated version of Hardhat
|
|
@@ -184,7 +184,8 @@ export async function printWelcomeMessage(): Promise<void> {
|
|
|
184
184
|
const latestHardhatVersion = await getLatestHardhatVersion();
|
|
185
185
|
if (hardhatVersion !== latestHardhatVersion) {
|
|
186
186
|
console.warn(
|
|
187
|
-
|
|
187
|
+
styleText(
|
|
188
|
+
["yellow", "bold"],
|
|
188
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`,
|
|
189
190
|
),
|
|
190
191
|
);
|
|
@@ -197,7 +198,8 @@ export async function printWelcomeMessage(): Promise<void> {
|
|
|
197
198
|
log("Couldn't report error to sentry: %O", e);
|
|
198
199
|
}
|
|
199
200
|
console.warn(
|
|
200
|
-
|
|
201
|
+
styleText(
|
|
202
|
+
["yellow", "bold"],
|
|
201
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`,
|
|
202
204
|
),
|
|
203
205
|
);
|
|
@@ -491,7 +493,7 @@ export async function copyProjectFiles(
|
|
|
491
493
|
await copy(absoluteTemplatePath, absoluteWorkspacePath);
|
|
492
494
|
}
|
|
493
495
|
|
|
494
|
-
console.log(`✨ ${
|
|
496
|
+
console.log(`✨ ${styleText("cyan", `Template files copied`)} ✨`);
|
|
495
497
|
}
|
|
496
498
|
|
|
497
499
|
/**
|
|
@@ -567,16 +569,25 @@ export async function installProjectDependencies(
|
|
|
567
569
|
console.log();
|
|
568
570
|
console.log(commandString);
|
|
569
571
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
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
|
+
}
|
|
578
589
|
|
|
579
|
-
console.log(`✨ ${
|
|
590
|
+
console.log(`✨ ${styleText("cyan", `Dependencies installed`)} ✨`);
|
|
580
591
|
}
|
|
581
592
|
}
|
|
582
593
|
|
|
@@ -611,26 +622,40 @@ export async function installProjectDependencies(
|
|
|
611
622
|
console.log();
|
|
612
623
|
console.log(commandString);
|
|
613
624
|
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
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
|
+
}
|
|
622
642
|
|
|
623
|
-
console.log(`✨ ${
|
|
643
|
+
console.log(`✨ ${styleText("cyan", `Dependencies updated`)} ✨`);
|
|
624
644
|
}
|
|
625
645
|
}
|
|
626
646
|
}
|
|
627
647
|
|
|
628
648
|
function showStarOnGitHubMessage() {
|
|
629
649
|
console.log(
|
|
630
|
-
|
|
650
|
+
styleText(
|
|
651
|
+
"cyan",
|
|
652
|
+
"Give Hardhat a star on GitHub if you're enjoying it! ⭐️✨",
|
|
653
|
+
),
|
|
631
654
|
);
|
|
632
655
|
console.log();
|
|
633
|
-
console.log(
|
|
656
|
+
console.log(
|
|
657
|
+
styleText("cyan", " https://github.com/NomicFoundation/hardhat"),
|
|
658
|
+
);
|
|
634
659
|
}
|
|
635
660
|
|
|
636
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
|
|
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
|
|
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
|
|
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<
|
|
212
|
+
): Promise<SemverVersion | undefined> {
|
|
211
213
|
if (version !== undefined) {
|
|
212
|
-
return
|
|
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
|
|
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${
|
|
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${
|
|
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
|
]);
|
package/src/internal/cli/main.ts
CHANGED
|
@@ -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 =
|
|
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:
|
|
756
|
+
log: DebugLogger,
|
|
756
757
|
) {
|
|
757
758
|
try {
|
|
758
759
|
// Based on Node.js resolution algorithm find the real path
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import { getRuntimeInfo } from "@nomicfoundation/hardhat-utils/runtime";
|
|
12
12
|
|
|
13
|
-
export const MIN_SUPPORTED_NODE_VERSION: number[] = [22,
|
|
13
|
+
export const MIN_SUPPORTED_NODE_VERSION: number[] = [22, 13, 0];
|
|
14
14
|
|
|
15
15
|
export function isNodeVersionSupported(): boolean {
|
|
16
16
|
try {
|
|
@@ -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 =
|
|
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";
|