hardhat 3.4.2 → 3.4.4
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 +37 -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.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/coverage/coverage-manager.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/coverage-manager.js +16 -16
- 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-classification/classifier.d.ts +58 -0
- package/dist/src/internal/cli/telemetry/error-classification/classifier.d.ts.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/classifier.js +402 -0
- package/dist/src/internal/cli/telemetry/error-classification/classifier.js.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/codebase-dependent-helpers.d.ts +67 -0
- package/dist/src/internal/cli/telemetry/error-classification/codebase-dependent-helpers.d.ts.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/codebase-dependent-helpers.js +140 -0
- package/dist/src/internal/cli/telemetry/error-classification/codebase-dependent-helpers.js.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/filter.d.ts +15 -0
- package/dist/src/internal/cli/telemetry/error-classification/filter.d.ts.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/filter.js +114 -0
- package/dist/src/internal/cli/telemetry/error-classification/filter.js.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/helpers.d.ts +52 -0
- package/dist/src/internal/cli/telemetry/error-classification/helpers.d.ts.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/helpers.js +163 -0
- package/dist/src/internal/cli/telemetry/error-classification/helpers.js.map +1 -0
- 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/error-reporter/reporter.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/error-reporter/reporter.js +14 -0
- package/dist/src/internal/cli/telemetry/error-reporter/reporter.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/anonymizer.d.ts +0 -2
- package/dist/src/internal/cli/telemetry/sentry/anonymizer.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/anonymizer.js +0 -117
- package/dist/src/internal/cli/telemetry/sentry/anonymizer.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/init.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/init.js +14 -9
- package/dist/src/internal/cli/telemetry/sentry/init.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/reporter.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/reporter.js +3 -29
- package/dist/src/internal/cli/telemetry/sentry/reporter.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/subprocess.js +13 -19
- 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 +21 -17
- 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-classification/classifier.ts +636 -0
- package/src/internal/cli/telemetry/error-classification/codebase-dependent-helpers.ts +200 -0
- package/src/internal/cli/telemetry/error-classification/filter.ts +140 -0
- package/src/internal/cli/telemetry/error-classification/helpers.ts +235 -0
- package/src/internal/cli/telemetry/error-reporter/global-error-handlers.ts +2 -2
- package/src/internal/cli/telemetry/error-reporter/reporter.ts +21 -0
- package/src/internal/cli/telemetry/sentry/anonymizer.ts +0 -168
- package/src/internal/cli/telemetry/sentry/init.ts +42 -33
- package/src/internal/cli/telemetry/sentry/reporter.ts +4 -47
- package/src/internal/cli/telemetry/sentry/subprocess.ts +13 -21
- 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 +7 -7
- 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,11 +1,12 @@
|
|
|
1
1
|
import type { ResolvedNpmPackage } from "../../../../../types/solidity.js";
|
|
2
2
|
import type { Result } from "../../../../../types/utils.js";
|
|
3
|
+
import type { TrueCasePathResolver } from "@nomicfoundation/hardhat-utils/fs";
|
|
3
4
|
|
|
4
5
|
import { assertHardhatInvariant } from "@nomicfoundation/hardhat-errors";
|
|
5
6
|
import { ensureError } from "@nomicfoundation/hardhat-utils/error";
|
|
6
7
|
import {
|
|
7
8
|
FileNotFoundError,
|
|
8
|
-
|
|
9
|
+
NotADirectoryError,
|
|
9
10
|
} from "@nomicfoundation/hardhat-utils/fs";
|
|
10
11
|
import { exports } from "resolve.exports";
|
|
11
12
|
|
|
@@ -15,6 +16,7 @@ export enum PathValidationErrorType {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export async function validateFsPath(
|
|
19
|
+
resolver: TrueCasePathResolver,
|
|
18
20
|
from: string,
|
|
19
21
|
relative: string,
|
|
20
22
|
): Promise<
|
|
@@ -26,14 +28,21 @@ export async function validateFsPath(
|
|
|
26
28
|
> {
|
|
27
29
|
let trueCaseFsPath: string;
|
|
28
30
|
try {
|
|
29
|
-
trueCaseFsPath = await getFileTrueCase(from, relative);
|
|
31
|
+
trueCaseFsPath = await resolver.getFileTrueCase(from, relative);
|
|
30
32
|
} catch (error) {
|
|
31
|
-
ensureError(error
|
|
33
|
+
ensureError(error);
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
error
|
|
36
|
-
|
|
35
|
+
if (
|
|
36
|
+
error instanceof FileNotFoundError ||
|
|
37
|
+
error instanceof NotADirectoryError
|
|
38
|
+
) {
|
|
39
|
+
return {
|
|
40
|
+
success: false,
|
|
41
|
+
error: { type: PathValidationErrorType.DOES_NOT_EXIST },
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
throw error;
|
|
37
46
|
}
|
|
38
47
|
|
|
39
48
|
if (relative !== trueCaseFsPath) {
|
|
@@ -1,19 +1,33 @@
|
|
|
1
|
+
import type { SemverVersion } from "@nomicfoundation/hardhat-utils/fast-semver";
|
|
2
|
+
|
|
1
3
|
import os from "node:os";
|
|
2
4
|
|
|
3
|
-
import
|
|
5
|
+
import { HardhatError } from "@nomicfoundation/hardhat-errors";
|
|
6
|
+
import {
|
|
7
|
+
greaterThanOrEqual,
|
|
8
|
+
lowerThan,
|
|
9
|
+
parseVersion,
|
|
10
|
+
} from "@nomicfoundation/hardhat-utils/fast-semver";
|
|
4
11
|
|
|
5
12
|
// The first solc version with official ARM64 Linux builds
|
|
6
|
-
export const FIRST_OFFICIAL_ARM64_SOLC_VERSION =
|
|
13
|
+
export const FIRST_OFFICIAL_ARM64_SOLC_VERSION: SemverVersion = [0, 8, 31];
|
|
7
14
|
|
|
8
15
|
// The lowest solc version available in the frozen ARM64 mirror repo
|
|
9
16
|
// (https://github.com/NomicFoundation/solc-linux-arm64-mirror/tree/main/public/linux/aarch64)
|
|
10
|
-
export const FIRST_ARM64_MIRROR_SOLC_VERSION =
|
|
17
|
+
export const FIRST_ARM64_MIRROR_SOLC_VERSION: SemverVersion = [0, 5, 0];
|
|
11
18
|
|
|
12
19
|
/**
|
|
13
20
|
* Determines if a solc version has an official ARM64 Linux build.
|
|
14
21
|
*/
|
|
15
22
|
export function hasOfficialArm64Build(version: string): boolean {
|
|
16
|
-
|
|
23
|
+
const parsed = parseVersion(version);
|
|
24
|
+
if (parsed === undefined) {
|
|
25
|
+
throw new HardhatError(
|
|
26
|
+
HardhatError.ERRORS.CORE.SOLIDITY.INVALID_SOLC_VERSION,
|
|
27
|
+
{ version },
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return greaterThanOrEqual(parsed, FIRST_OFFICIAL_ARM64_SOLC_VERSION);
|
|
17
31
|
}
|
|
18
32
|
|
|
19
33
|
/**
|
|
@@ -21,9 +35,16 @@ export function hasOfficialArm64Build(version: string): boolean {
|
|
|
21
35
|
* in the community mirror (versions 0.5.0–0.8.30).
|
|
22
36
|
*/
|
|
23
37
|
export function hasArm64MirrorBuild(version: string): boolean {
|
|
38
|
+
const parsed = parseVersion(version);
|
|
39
|
+
if (parsed === undefined) {
|
|
40
|
+
throw new HardhatError(
|
|
41
|
+
HardhatError.ERRORS.CORE.SOLIDITY.INVALID_SOLC_VERSION,
|
|
42
|
+
{ version },
|
|
43
|
+
);
|
|
44
|
+
}
|
|
24
45
|
return (
|
|
25
|
-
|
|
26
|
-
|
|
46
|
+
greaterThanOrEqual(parsed, FIRST_ARM64_MIRROR_SOLC_VERSION) &&
|
|
47
|
+
lowerThan(parsed, FIRST_OFFICIAL_ARM64_SOLC_VERSION)
|
|
27
48
|
);
|
|
28
49
|
}
|
|
29
50
|
|
|
@@ -32,7 +32,10 @@ import {
|
|
|
32
32
|
hasOfficialArm64Build,
|
|
33
33
|
missesSomeOfficialNativeBuilds,
|
|
34
34
|
} from "./build-system/solc-info.js";
|
|
35
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
DEFAULT_OUTPUT_SELECTION,
|
|
37
|
+
SOLC_DEFAULT_OPTIMIZER_RUNS,
|
|
38
|
+
} from "./constants.js";
|
|
36
39
|
|
|
37
40
|
/**
|
|
38
41
|
* The top-level type SolidityUserConfig is a union type too complex for
|
|
@@ -542,7 +545,7 @@ function resolveSolidityCompilerConfig(
|
|
|
542
545
|
if (production && isSolcSolidityCompilerUserConfig(compilerConfig)) {
|
|
543
546
|
defaultSettings.optimizer = {
|
|
544
547
|
enabled: true,
|
|
545
|
-
runs:
|
|
548
|
+
runs: SOLC_DEFAULT_OPTIMIZER_RUNS,
|
|
546
549
|
};
|
|
547
550
|
}
|
|
548
551
|
|
|
@@ -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.
|