diff --git a/.changeset/light-beds-tap.md b/.changeset/light-beds-tap.md new file mode 100644 index 0000000000..8f039eed03 --- /dev/null +++ b/.changeset/light-beds-tap.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/hardhat-foundry": patch +--- + +Replace chalk with picocolor diff --git a/.changeset/purple-starfishes-drive.md b/.changeset/purple-starfishes-drive.md new file mode 100644 index 0000000000..e5187f8716 --- /dev/null +++ b/.changeset/purple-starfishes-drive.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/hardhat-viem": patch +--- + +Remove unnecessary peerDependency diff --git a/.changeset/smart-rocks-develop.md b/.changeset/smart-rocks-develop.md new file mode 100644 index 0000000000..fd675ffb7e --- /dev/null +++ b/.changeset/smart-rocks-develop.md @@ -0,0 +1,5 @@ +--- +"hardhat": patch +--- + +Replaced `chalk` with `picocolors`, `glob` with `tinyglob`, and upgraded `find-up` diff --git a/.changeset/unlucky-humans-dream.md b/.changeset/unlucky-humans-dream.md new file mode 100644 index 0000000000..9b56ca6584 --- /dev/null +++ b/.changeset/unlucky-humans-dream.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/hardhat-verify": patch +--- + +Replace chalk with picocolors diff --git a/config/eslint/constants.js b/config/eslint/constants.js index ae18c712a2..9b37675e7c 100644 --- a/config/eslint/constants.js +++ b/config/eslint/constants.js @@ -1,5 +1,5 @@ module.exports.slowImportsCommonIgnoredModules = [ - "chalk", + "picocolors", "debug", "find-up", "fs-extra", diff --git a/packages/hardhat-core/package.json b/packages/hardhat-core/package.json index b12a62a377..e7b0da707c 100644 --- a/packages/hardhat-core/package.json +++ b/packages/hardhat-core/package.json @@ -66,9 +66,7 @@ "@types/chai-as-promised": "^7.1.3", "@types/ci-info": "^2.0.0", "@types/debug": "^4.1.4", - "@types/find-up": "^2.1.1", "@types/fs-extra": "^5.1.0", - "@types/glob": "^7.1.1", "@types/keccak": "^3.0.1", "@types/lodash": "^4.14.123", "@types/mocha": ">=9.1.0", @@ -114,7 +112,6 @@ "aggregate-error": "^3.0.0", "ansi-escapes": "^4.3.0", "boxen": "^5.1.2", - "chalk": "^2.4.2", "chokidar": "^4.0.0", "ci-info": "^2.0.0", "debug": "^4.1.1", @@ -122,10 +119,9 @@ "env-paths": "^2.2.0", "ethereum-cryptography": "^1.0.3", "ethereumjs-abi": "^0.6.8", - "find-up": "^2.1.0", + "find-up": "^5.0.0", "fp-ts": "1.19.3", "fs-extra": "^7.0.1", - "glob": "7.2.0", "immutable": "^4.0.0-rc.12", "io-ts": "1.10.4", "json-stream-stringify": "^3.1.4", @@ -134,12 +130,14 @@ "mnemonist": "^0.38.0", "mocha": "^10.0.0", "p-map": "^4.0.0", + "picocolors": "^1.1.0", "raw-body": "^2.4.1", "resolve": "1.17.0", "semver": "^6.3.0", "solc": "0.8.26", "source-map-support": "^0.5.13", "stacktrace-parser": "^0.1.10", + "tinyglobby": "^0.2.6", "tsort": "0.0.1", "undici": "^5.14.0", "uuid": "^8.3.2", diff --git a/packages/hardhat-core/src/builtin-tasks/compile.ts b/packages/hardhat-core/src/builtin-tasks/compile.ts index 88454dbdc4..14a1a92b5e 100644 --- a/packages/hardhat-core/src/builtin-tasks/compile.ts +++ b/packages/hardhat-core/src/builtin-tasks/compile.ts @@ -1,5 +1,5 @@ import os from "os"; -import chalk from "chalk"; +import picocolors from "picocolors"; import debug from "debug"; import fsExtra from "fs-extra"; import semver from "semver"; @@ -800,11 +800,15 @@ subtask(TASK_COMPILE_SOLIDITY_LOG_COMPILATION_ERRORS) getFormattedInternalCompilerErrorMessage(error) ?? error.formattedMessage; - console.error(errorMessage.replace(/^\w+:/, (t) => chalk.red.bold(t))); + console.error( + errorMessage.replace(/^\w+:/, (t) => + picocolors.bold(picocolors.red(t)) + ) + ); } else { console.warn( (error.formattedMessage as string).replace(/^\w+:/, (t) => - chalk.yellow.bold(t) + picocolors.bold(picocolors.yellow(t)) ) ); } @@ -813,7 +817,7 @@ subtask(TASK_COMPILE_SOLIDITY_LOG_COMPILATION_ERRORS) const hasConsoleErrors: boolean = output.errors.some(isConsoleLogError); if (hasConsoleErrors) { console.error( - chalk.red( + picocolors.red( `The console.log call you made isn’t supported. See https://hardhat.org/console-log for the list of supported methods.` ) ); diff --git a/packages/hardhat-core/src/builtin-tasks/flatten.ts b/packages/hardhat-core/src/builtin-tasks/flatten.ts index c37b1a5af6..28e6a65c88 100644 --- a/packages/hardhat-core/src/builtin-tasks/flatten.ts +++ b/packages/hardhat-core/src/builtin-tasks/flatten.ts @@ -1,4 +1,4 @@ -import chalk from "chalk"; +import picocolors from "picocolors"; import { subtask, task, types } from "../internal/core/config/config-env"; import { HardhatError } from "../internal/core/errors"; import { ERRORS } from "../internal/core/errors-list"; @@ -313,7 +313,7 @@ task( if (metadata.filesWithoutLicenses.length > 0) { console.warn( - chalk.yellow( + picocolors.yellow( `\nThe following file(s) do NOT specify SPDX licenses: ${metadata.filesWithoutLicenses.join( ", " )}` @@ -326,7 +326,7 @@ task( metadata.filesWithoutPragmaDirectives.length > 0 ) { console.warn( - chalk.yellow( + picocolors.yellow( `\nPragma abicoder directives are defined in some files, but they are not defined in the following ones: ${metadata.filesWithoutPragmaDirectives.join( ", " )}` @@ -336,7 +336,7 @@ task( if (metadata.filesWithDifferentPragmaDirectives.length > 0) { console.warn( - chalk.yellow( + picocolors.yellow( `\nThe flattened file is using the pragma abicoder directive '${ metadata.pragmaDirective }' but these files have a different pragma abicoder directive: ${metadata.filesWithDifferentPragmaDirectives.join( diff --git a/packages/hardhat-core/src/builtin-tasks/node.ts b/packages/hardhat-core/src/builtin-tasks/node.ts index c44bee6eea..ee4ff36360 100644 --- a/packages/hardhat-core/src/builtin-tasks/node.ts +++ b/packages/hardhat-core/src/builtin-tasks/node.ts @@ -1,6 +1,6 @@ import type EthereumjsUtilT from "@nomicfoundation/ethereumjs-util"; -import chalk from "chalk"; +import picocolors from "picocolors"; import debug from "debug"; import fsExtra from "fs-extra"; @@ -35,12 +35,12 @@ const log = debug("hardhat:core:tasks:node"); function printDefaultConfigWarning() { console.log( - chalk.bold( + picocolors.bold( "WARNING: These accounts, and their private keys, are publicly known." ) ); console.log( - chalk.bold( + picocolors.bold( "Any funds sent to them on Mainnet or any other live network WILL BE LOST." ) ); @@ -237,7 +237,7 @@ subtask(TASK_NODE_SERVER_READY) { config } ) => { console.log( - chalk.green( + picocolors.green( `Started HTTP and WebSocket JSON-RPC server at http://${address}:${port}/` ) ); @@ -339,7 +339,7 @@ task(TASK_NODE, "Starts a JSON-RPC server on top of Hardhat Network") watcher = await watchCompilerOutput(provider, config.paths); } catch (error) { console.warn( - chalk.yellow( + picocolors.yellow( "There was a problem watching the compiler output, changes in the contracts won't be reflected in the Hardhat Network. Run Hardhat with --verbose to learn more." ) ); diff --git a/packages/hardhat-core/src/builtin-tasks/test.ts b/packages/hardhat-core/src/builtin-tasks/test.ts index d6a5577571..b6785d830b 100644 --- a/packages/hardhat-core/src/builtin-tasks/test.ts +++ b/packages/hardhat-core/src/builtin-tasks/test.ts @@ -1,6 +1,6 @@ import type { MochaOptions } from "mocha"; -import chalk from "chalk"; +import picocolors from "picocolors"; import path from "path"; import { HARDHAT_NETWORK_NAME } from "../internal/constants"; @@ -207,7 +207,7 @@ task(TASK_TEST, "Runs mocha tests") if (stackTracesFailures !== 0) { console.warn( - chalk.yellow( + picocolors.yellow( `Failed to generate ${stackTracesFailures} ${pluralize( stackTracesFailures, "stack trace" diff --git a/packages/hardhat-core/src/builtin-tasks/utils/watch.ts b/packages/hardhat-core/src/builtin-tasks/utils/watch.ts index 37817a88d7..b79cf20fa1 100644 --- a/packages/hardhat-core/src/builtin-tasks/utils/watch.ts +++ b/packages/hardhat-core/src/builtin-tasks/utils/watch.ts @@ -1,4 +1,4 @@ -import chalk from "chalk"; +import picocolors from "picocolors"; import { FSWatcher } from "chokidar"; import debug from "debug"; import fsExtra from "fs-extra"; @@ -34,7 +34,7 @@ export async function watchCompilerOutput( }); } catch (error) { console.warn( - chalk.yellow( + picocolors.yellow( "There was a problem adding the new compiler result. Run Hardhat with --verbose to learn more." ) ); diff --git a/packages/hardhat-core/src/internal/cli/autocomplete.ts b/packages/hardhat-core/src/internal/cli/autocomplete.ts index 10ebe09b38..82eb3773ff 100644 --- a/packages/hardhat-core/src/internal/cli/autocomplete.ts +++ b/packages/hardhat-core/src/internal/cli/autocomplete.ts @@ -307,7 +307,7 @@ function getTaskFromTaskDefinition(taskDef: TaskDefinition): Task { function getProjectId(): string | undefined { const packageJsonPath = findup.sync("package.json"); - if (packageJsonPath === null) { + if (packageJsonPath === undefined) { return undefined; } diff --git a/packages/hardhat-core/src/internal/cli/bootstrap.ts b/packages/hardhat-core/src/internal/cli/bootstrap.ts index 7668019292..2b05f8e003 100644 --- a/packages/hardhat-core/src/internal/cli/bootstrap.ts +++ b/packages/hardhat-core/src/internal/cli/bootstrap.ts @@ -1,12 +1,12 @@ #!/usr/bin/env node -import chalk from "chalk"; +import picocolors from "picocolors"; import { isNodeVersionToWarnOn } from "./is-node-version-to-warn-on"; if (isNodeVersionToWarnOn(process.version)) { console.warn( - chalk.yellow.bold(`WARNING:`), + picocolors.yellow(picocolors.bold(`WARNING:`)), `You are currently using Node.js ${process.version}, which is not supported by Hardhat. This can lead to unexpected behavior. See https://hardhat.org/nodejs-versions` ); console.log(); diff --git a/packages/hardhat-core/src/internal/cli/cli.ts b/packages/hardhat-core/src/internal/cli/cli.ts index f31f1c8aec..c00c3a0137 100755 --- a/packages/hardhat-core/src/internal/cli/cli.ts +++ b/packages/hardhat-core/src/internal/cli/cli.ts @@ -1,4 +1,4 @@ -import chalk from "chalk"; +import picocolors from "picocolors"; import debug from "debug"; import "source-map-support/register"; @@ -102,7 +102,7 @@ function showViaIRWarning(resolvedConfig: HardhatConfig) { if (viaIREnabled) { console.warn(); console.warn( - chalk.yellow( + picocolors.yellow( `Your solidity settings have viaIR enabled, which is not fully supported yet. You can still use Hardhat, but some features, like stack traces, might not work correctly. Learn more at https://hardhat.org/solc-viair` @@ -170,14 +170,16 @@ async function main() { // Warning for Hardhat V3 deprecation console.warn( - chalk.yellow.bold("\n\nDEPRECATION WARNING\n\n"), - chalk.yellow( - `Initializing a project with ${chalk.white.italic( - "npx hardhat" + picocolors.yellow(picocolors.bold("\n\nDEPRECATION WARNING\n\n")), + picocolors.yellow( + `Initializing a project with ${picocolors.white( + picocolors.italic("npx hardhat") )} is deprecated and will be removed in the future.\n` ), - chalk.yellow( - `Please use ${chalk.white.italic("npx hardhat init")} instead.\n\n` + picocolors.yellow( + `Please use ${picocolors.white( + picocolors.italic("npx hardhat init") + )} instead.\n\n` ) ); @@ -387,20 +389,22 @@ async function main() { if (HardhatError.isHardhatError(error)) { isHardhatError = true; console.error( - chalk.red.bold("Error"), - error.message.replace(/^\w+:/, (t) => chalk.red.bold(t)) + picocolors.red(picocolors.bold("Error")), + error.message.replace(/^\w+:/, (t) => + picocolors.red(picocolors.bold(t)) + ) ); } else if (HardhatPluginError.isHardhatPluginError(error)) { isHardhatError = true; console.error( - chalk.red.bold(`Error in plugin ${error.pluginName}:`), + picocolors.red(picocolors.bold(`Error in plugin ${error.pluginName}:`)), error.message ); } else if (error instanceof Error) { - console.error(chalk.red("An unexpected error occurred:")); + console.error(picocolors.red("An unexpected error occurred:")); showStackTraces = true; } else { - console.error(chalk.red("An unexpected error occurred.")); + console.error(picocolors.red("An unexpected error occurred.")); showStackTraces = true; } diff --git a/packages/hardhat-core/src/internal/cli/project-creation.ts b/packages/hardhat-core/src/internal/cli/project-creation.ts index 43ac320bf6..1d3a10c841 100644 --- a/packages/hardhat-core/src/internal/cli/project-creation.ts +++ b/packages/hardhat-core/src/internal/cli/project-creation.ts @@ -1,4 +1,4 @@ -import chalk from "chalk"; +import picocolors from "picocolors"; import fsExtra from "fs-extra"; import path from "path"; @@ -97,28 +97,34 @@ const TYPESCRIPT_VIEM_PEER_DEPENDENCIES: Dependencies = { // generated with the "colossal" font function printAsciiLogo() { console.log( - chalk.blue("888 888 888 888 888") + picocolors.blue("888 888 888 888 888") ); console.log( - chalk.blue("888 888 888 888 888") + picocolors.blue("888 888 888 888 888") ); console.log( - chalk.blue("888 888 888 888 888") + picocolors.blue("888 888 888 888 888") ); console.log( - chalk.blue("8888888888 8888b. 888d888 .d88888 88888b. 8888b. 888888") + picocolors.blue( + "8888888888 8888b. 888d888 .d88888 88888b. 8888b. 888888" + ) ); console.log( - chalk.blue('888 888 "88b 888P" d88" 888 888 "88b "88b 888') + picocolors.blue('888 888 "88b 888P" d88" 888 888 "88b "88b 888') ); console.log( - chalk.blue("888 888 .d888888 888 888 888 888 888 .d888888 888") + picocolors.blue("888 888 .d888888 888 888 888 888 888 .d888888 888") ); console.log( - chalk.blue("888 888 888 888 888 Y88b 888 888 888 888 888 Y88b.") + picocolors.blue( + "888 888 888 888 888 Y88b 888 888 888 888 888 Y88b." + ) ); console.log( - chalk.blue('888 888 "Y888888 888 "Y88888 888 888 "Y888888 "Y888') + picocolors.blue( + '888 888 "Y888888 888 "Y88888 888 888 "Y888888 "Y888' + ) ); console.log(""); } @@ -127,7 +133,7 @@ async function printWelcomeMessage() { const packageJson = await getPackageJson(); console.log( - chalk.cyan( + picocolors.cyan( `${emoji("πŸ‘· ")}Welcome to ${HARDHAT_NAME} v${packageJson.version}${emoji( " πŸ‘·β€" )}\n` @@ -200,7 +206,7 @@ Please delete or rename ${pluralize( "it", "them" )} and try again.`; - console.log(chalk.red(errorMsg)); + console.log(picocolors.red(errorMsg)); process.exit(1); } @@ -356,11 +362,13 @@ async function createPackageJson() { function showStarOnGitHubMessage() { console.log( - chalk.cyan("Give Hardhat a star on Github if you're enjoying it!") + + picocolors.cyan("Give Hardhat a star on Github if you're enjoying it!") + emoji(" ⭐️✨") ); console.log(); - console.log(chalk.cyan(" https://github.com/NomicFoundation/hardhat")); + console.log( + picocolors.cyan(" https://github.com/NomicFoundation/hardhat") + ); } export function showSoliditySurveyMessage() { @@ -371,7 +379,7 @@ export function showSoliditySurveyMessage() { console.log(); console.log( - chalk.cyan( + picocolors.cyan( "Please take a moment to complete the 2023 Solidity Survey: https://hardhat.org/solidity-survey-2023" ) ); @@ -405,7 +413,7 @@ export async function createProject() { if (action === Action.CREATE_EMPTY_HARDHAT_CONFIG_ACTION) { await writeEmptyHardhatConfig(isEsm); console.log( - `${emoji("✨ ")}${chalk.cyan(`Config file created`)}${emoji(" ✨")}` + `${emoji("✨ ")}${picocolors.cyan(`Config file created`)}${emoji(" ✨")}` ); if (!isInstalled(HARDHAT_PACKAGE_NAME)) { @@ -504,7 +512,9 @@ export async function createProject() { if (!installed) { console.warn( - chalk.red("Failed to install the sample project's dependencies") + picocolors.red( + "Failed to install the sample project's dependencies" + ) ); } @@ -519,7 +529,7 @@ export async function createProject() { } console.log( - `\n${emoji("✨ ")}${chalk.cyan("Project created")}${emoji(" ✨")}` + `\n${emoji("✨ ")}${picocolors.cyan("Project created")}${emoji(" ✨")}` ); console.log(); console.log("See the README.md file for some example tasks you can run"); diff --git a/packages/hardhat-core/src/internal/cli/vars.ts b/packages/hardhat-core/src/internal/cli/vars.ts index 7a36f80920..385077b484 100644 --- a/packages/hardhat-core/src/internal/cli/vars.ts +++ b/packages/hardhat-core/src/internal/cli/vars.ts @@ -1,4 +1,4 @@ -import chalk from "chalk"; +import picocolors from "picocolors"; import debug from "debug"; import { HardhatError, assertHardhatInvariant } from "../core/errors"; import { ERRORS } from "../core/errors-list"; @@ -35,7 +35,7 @@ export async function handleVars( case "setup": return setup(configPath); default: - console.error(chalk.red(`Invalid task '${taskDefinition.name}'`)); + console.error(picocolors.red(`Invalid task '${taskDefinition.name}'`)); return 1; // Error code } } @@ -65,7 +65,7 @@ function get(key: string): number { } console.warn( - chalk.yellow( + picocolors.yellow( `The configuration variable '${key}' is not set in ${HardhatContext.getHardhatContext().varsManager.getStoragePath()}` ) ); @@ -88,7 +88,7 @@ function list(): number { } else { if (process.stdout.isTTY) { console.warn( - chalk.yellow( + picocolors.yellow( `There are no configuration variables stored in ${varsStoragePath}` ) ); @@ -112,7 +112,7 @@ function del(key: string): number { } console.warn( - chalk.yellow( + picocolors.yellow( `There is no configuration variable '${key}' to delete from ${varsStoragePath}` ) ); @@ -137,7 +137,7 @@ function setup(configPath: string | undefined) { loadConfigFile(configPath); } catch (err: any) { console.error( - chalk.red( + picocolors.red( "There is an error in your Hardhat configuration file. Please double check it.\n" ) ); @@ -187,7 +187,7 @@ function listVarsToSetup(varsManagerSetup: VarsManagerSetup) { if (requiredKeysToSet.length === 0 && optionalKeysToSet.length === 0) { console.log( - chalk.green( + picocolors.green( "There are no configuration variables that need to be set for this project" ) ); @@ -198,7 +198,7 @@ function listVarsToSetup(varsManagerSetup: VarsManagerSetup) { if (requiredKeysToSet.length > 0) { console.log( - chalk.bold( + picocolors.bold( `${emoji("❗ ")}The following configuration variables need to be set:\n` ) ); @@ -210,7 +210,7 @@ function listVarsToSetup(varsManagerSetup: VarsManagerSetup) { if (optionalKeysToSet.length > 0) { console.log( - chalk.bold( + picocolors.bold( `${emoji("πŸ’‘ ")}The following configuration variables are optional:\n` ) ); @@ -237,7 +237,7 @@ function printAlreadySetKeys(varsManagerSetup: VarsManagerSetup) { } console.log( - `${chalk.bold(`${emoji("βœ”οΈ ")}Configuration variables already set:`)}` + `${picocolors.bold(`${emoji("βœ”οΈ ")}Configuration variables already set:`)}` ); console.log(); diff --git a/packages/hardhat-core/src/internal/cli/version-notifier.ts b/packages/hardhat-core/src/internal/cli/version-notifier.ts index 1ac7ececee..c18a6d6052 100644 --- a/packages/hardhat-core/src/internal/cli/version-notifier.ts +++ b/packages/hardhat-core/src/internal/cli/version-notifier.ts @@ -1,5 +1,5 @@ import boxen from "boxen"; -import chalk from "chalk"; +import picocolors from "picocolors"; import fsExtra from "fs-extra"; import { join } from "node:path"; import { mkdir, readFile, writeFile } from "node:fs/promises"; @@ -111,9 +111,9 @@ export async function showNewVersionNotification() { console.log( boxen( - `New Hardhat release available! ${chalk.red( + `New Hardhat release available! ${picocolors.red( hardhatVersion - )} -> ${chalk.green(latestV2Version)}. + )} -> ${picocolors.green(latestV2Version)}. Changelog: https://hardhat.org/release/${latestV2Version} diff --git a/packages/hardhat-core/src/internal/core/config/config-loading.ts b/packages/hardhat-core/src/internal/core/config/config-loading.ts index 751151c07e..e17967faa4 100644 --- a/packages/hardhat-core/src/internal/core/config/config-loading.ts +++ b/packages/hardhat-core/src/internal/core/config/config-loading.ts @@ -1,6 +1,6 @@ import type StackTraceParserT from "stacktrace-parser"; -import chalk from "chalk"; +import picocolors from "picocolors"; import debug from "debug"; import fsExtra from "fs-extra"; import path from "path"; @@ -198,7 +198,7 @@ export function analyzeModuleNotFoundError(error: any, configPath: string) { const packageJsonPath = findClosestPackageJson(throwingFile); - if (packageJsonPath === null) { + if (packageJsonPath === undefined) { return; } @@ -281,14 +281,14 @@ function checkEmptyConfig( warning += `\nLearn more about configuring Hardhat at https://hardhat.org/config\n`; } - console.warn(chalk.yellow(warning)); + console.warn(picocolors.yellow(warning)); } } function checkMissingSolidityConfig(userConfig: any) { if (userConfig.solidity === undefined) { console.warn( - chalk.yellow( + picocolors.yellow( `Solidity compiler is not configured. Version ${DEFAULT_SOLC_VERSION} will be used by default. Add a 'solidity' entry to your configuration to suppress this warning. Learn more about compiler configuration at https://hardhat.org/config @@ -314,7 +314,7 @@ function checkUnsupportedSolidityConfig(resolvedConfig: HardhatConfig) { if (unsupportedVersions.length > 0) { console.warn( - chalk.yellow( + picocolors.yellow( `Solidity ${unsupportedVersions.join(", ")} ${ unsupportedVersions.length === 1 ? "is" : "are" } not fully supported yet. You can still use Hardhat, but some features, like stack traces, might not work correctly. @@ -337,7 +337,7 @@ function checkUnsupportedRemappings({ solidity }: HardhatConfig) { if (remappings.length > 0) { console.warn( - chalk.yellow( + picocolors.yellow( `Solidity remappings are not currently supported; you may experience unexpected compilation results. Remove any 'remappings' fields from your configuration to suppress this warning. Learn more about compiler configuration at https://hardhat.org/config diff --git a/packages/hardhat-core/src/internal/core/project-structure.ts b/packages/hardhat-core/src/internal/core/project-structure.ts index 1ccf6ecfec..26f67b8a09 100644 --- a/packages/hardhat-core/src/internal/core/project-structure.ts +++ b/packages/hardhat-core/src/internal/core/project-structure.ts @@ -14,31 +14,31 @@ const CTS_CONFIG_FILENAME = "hardhat.config.cts"; export function isCwdInsideProject() { return ( - findUp.sync(TS_CONFIG_FILENAME) !== null || - findUp.sync(CTS_CONFIG_FILENAME) !== null || - findUp.sync(CJS_CONFIG_FILENAME) !== null || - findUp.sync(JS_CONFIG_FILENAME) !== null + findUp.sync(TS_CONFIG_FILENAME) !== undefined || + findUp.sync(CTS_CONFIG_FILENAME) !== undefined || + findUp.sync(CJS_CONFIG_FILENAME) !== undefined || + findUp.sync(JS_CONFIG_FILENAME) !== undefined ); } export function getUserConfigPath() { const tsConfigPath = findUp.sync(TS_CONFIG_FILENAME); - if (tsConfigPath !== null) { + if (tsConfigPath !== undefined) { return tsConfigPath; } const ctsConfigPath = findUp.sync(CTS_CONFIG_FILENAME); - if (ctsConfigPath !== null) { + if (ctsConfigPath !== undefined) { return ctsConfigPath; } const cjsConfigPath = findUp.sync(CJS_CONFIG_FILENAME); - if (cjsConfigPath !== null) { + if (cjsConfigPath !== undefined) { return cjsConfigPath; } const pathToConfigFile = findUp.sync(JS_CONFIG_FILENAME); - if (pathToConfigFile === null) { + if (pathToConfigFile === undefined) { throw new HardhatError(ERRORS.GENERAL.NOT_INSIDE_PROJECT); } diff --git a/packages/hardhat-core/src/internal/hardhat-network/provider/provider.ts b/packages/hardhat-core/src/internal/hardhat-network/provider/provider.ts index 359f982be2..b43e2565d8 100644 --- a/packages/hardhat-core/src/internal/hardhat-network/provider/provider.ts +++ b/packages/hardhat-core/src/internal/hardhat-network/provider/provider.ts @@ -19,7 +19,7 @@ import type { HttpHeader, } from "@nomicfoundation/edr"; import { Common } from "@nomicfoundation/ethereumjs-common"; -import chalk from "chalk"; +import picocolors from "picocolors"; import debug from "debug"; import { EventEmitter } from "events"; import fsExtra from "fs-extra"; @@ -559,7 +559,7 @@ export class EdrProviderWrapper ); } catch (error) { console.warn( - chalk.yellow( + picocolors.yellow( "The Hardhat Network tracing engine could not be updated. Run Hardhat with --verbose to learn more." ) ); @@ -662,7 +662,7 @@ async function makeTracingConfig( }; } catch (error) { console.warn( - chalk.yellow( + picocolors.yellow( "Stack traces engine could not be initialized. Run Hardhat with --verbose to learn more." ) ); diff --git a/packages/hardhat-core/src/internal/hardhat-network/provider/utils/fork-recomendations-banner.ts b/packages/hardhat-core/src/internal/hardhat-network/provider/utils/fork-recomendations-banner.ts index a8782aa94f..9436748194 100644 --- a/packages/hardhat-core/src/internal/hardhat-network/provider/utils/fork-recomendations-banner.ts +++ b/packages/hardhat-core/src/internal/hardhat-network/provider/utils/fork-recomendations-banner.ts @@ -1,4 +1,4 @@ -import chalk from "chalk"; +import picocolors from "picocolors"; import fsExtra from "fs-extra"; import path from "path"; @@ -10,7 +10,7 @@ function getAlreadyShownFilePath(forkCachePath: string) { function displayBanner() { console.warn( - chalk.yellow( + picocolors.yellow( `You're running a network fork starting from the latest block. Performance may degrade due to fetching data from the network with each run. If connecting to an archival node (e.g. Alchemy), we strongly recommend setting diff --git a/packages/hardhat-core/src/internal/hardhat-network/provider/utils/makeForkClient.ts b/packages/hardhat-core/src/internal/hardhat-network/provider/utils/makeForkClient.ts index cc006ec9ab..49347d1b96 100644 --- a/packages/hardhat-core/src/internal/hardhat-network/provider/utils/makeForkClient.ts +++ b/packages/hardhat-core/src/internal/hardhat-network/provider/utils/makeForkClient.ts @@ -1,4 +1,4 @@ -import chalk from "chalk"; +import picocolors from "picocolors"; import { HARDHAT_NETWORK_NAME } from "../../../constants"; import { assertHardhatInvariant } from "../../../core/errors"; @@ -61,7 +61,7 @@ export async function makeForkProvider(forkConfig: ForkConfig): Promise<{ latestBlockNumber - BigInt(forkConfig.blockNumber) + 1n; const requiredConfirmations = maxReorg + 1n; console.warn( - chalk.yellow( + picocolors.yellow( `You are forking from block ${ forkConfig.blockNumber }, which has less than ${requiredConfirmations} confirmations, and will affect Hardhat Network's performance. diff --git a/packages/hardhat-core/src/internal/hardhat-network/stack-traces/vm-trace-decoder.ts b/packages/hardhat-core/src/internal/hardhat-network/stack-traces/vm-trace-decoder.ts index a0bf98769b..b3b190df3a 100644 --- a/packages/hardhat-core/src/internal/hardhat-network/stack-traces/vm-trace-decoder.ts +++ b/packages/hardhat-core/src/internal/hardhat-network/stack-traces/vm-trace-decoder.ts @@ -1,5 +1,5 @@ import type { VmTraceDecoder as VmTraceDecoderT } from "@nomicfoundation/edr"; -import chalk from "chalk"; +import picocolors from "picocolors"; import debug from "debug"; import { Reporter } from "../../sentry/reporter"; import { TracingConfig } from "../provider/node-types"; @@ -19,7 +19,7 @@ function initializeVmTraceDecoderWrapper( initializeVmTraceDecoder(vmTraceDecoder, tracingConfig); } catch (error) { console.warn( - chalk.yellow( + picocolors.yellow( "The Hardhat Network tracing engine could not be initialized. Run Hardhat with --verbose to learn more." ) ); diff --git a/packages/hardhat-core/src/internal/sentry/anonymizer.ts b/packages/hardhat-core/src/internal/sentry/anonymizer.ts index 1a5a52b0f3..bbf694b303 100644 --- a/packages/hardhat-core/src/internal/sentry/anonymizer.ts +++ b/packages/hardhat-core/src/internal/sentry/anonymizer.ts @@ -59,7 +59,7 @@ export class Anonymizer { if (filename === this._configPath) { const packageJsonPath = this._getFilePackageJsonPath(filename); - if (packageJsonPath === null) { + if (packageJsonPath === undefined) { // if we can't find a package.json, we just return the basename return { anonymizedFilename: path.basename(filename), @@ -163,7 +163,7 @@ export class Anonymizer { return false; } - protected _getFilePackageJsonPath(filename: string): string | null { + protected _getFilePackageJsonPath(filename: string): string | undefined { return findup.sync("package.json", { cwd: path.dirname(filename), }); diff --git a/packages/hardhat-core/src/internal/util/caller-package.ts b/packages/hardhat-core/src/internal/util/caller-package.ts index 7c31a91005..e90916b837 100644 --- a/packages/hardhat-core/src/internal/util/caller-package.ts +++ b/packages/hardhat-core/src/internal/util/caller-package.ts @@ -1,7 +1,7 @@ import findup from "find-up"; import path from "path"; -function findClosestPackageJson(file: string): string | null { +function findClosestPackageJson(file: string): string | undefined { return findup.sync("package.json", { cwd: path.dirname(file) }); } @@ -35,7 +35,7 @@ export function getClosestCallerPackage(): string | undefined { continue; } - if (callerPackage === null) { + if (callerPackage === undefined) { return undefined; } diff --git a/packages/hardhat-core/src/internal/util/glob.ts b/packages/hardhat-core/src/internal/util/glob.ts index 41ad6aea5a..afe82744dd 100644 --- a/packages/hardhat-core/src/internal/util/glob.ts +++ b/packages/hardhat-core/src/internal/util/glob.ts @@ -1,7 +1,5 @@ -import type { IOptions as GlobOptions } from "glob"; - +import type { GlobOptions } from "tinyglobby"; import * as path from "path"; -import util from "util"; /** * DO NOT USE THIS FUNCTION. It's SLOW and its semantics are optimized for @@ -16,8 +14,7 @@ export async function glob( pattern: string, options: GlobOptions = {} ): Promise { - const { default: globModule } = await import("glob"); - const files = await util.promisify(globModule)(pattern, options); + const files = await (await import("tinyglobby")).glob([pattern], options); return files.map(path.normalize); } @@ -26,6 +23,9 @@ export async function glob( * @see glob */ export function globSync(pattern: string, options: GlobOptions = {}): string[] { - const files = require("glob").sync(pattern, options); + const files = (require("tinyglobby") as typeof import("tinyglobby")).globSync( + [pattern], + options + ); return files.map(path.normalize); } diff --git a/packages/hardhat-core/src/internal/util/packageInfo.ts b/packages/hardhat-core/src/internal/util/packageInfo.ts index b2f678a8a4..50dc5409e2 100644 --- a/packages/hardhat-core/src/internal/util/packageInfo.ts +++ b/packages/hardhat-core/src/internal/util/packageInfo.ts @@ -23,13 +23,13 @@ export interface PackageJson { }; } -export function findClosestPackageJson(file: string): string | null { +export function findClosestPackageJson(file: string): string | undefined { return findup.sync("package.json", { cwd: path.dirname(file) }); } export async function getPackageName(file: string): Promise { const packageJsonPath = findClosestPackageJson(file); - if (packageJsonPath !== null && packageJsonPath !== "") { + if (packageJsonPath !== undefined && packageJsonPath !== "") { const packageJson: PackageJson = await fsExtra.readJSON(packageJsonPath); return packageJson.name; } @@ -45,7 +45,7 @@ export function getHardhatVersion(): string { const packageJsonPath = findClosestPackageJson(__filename); assertHardhatInvariant( - packageJsonPath !== null, + packageJsonPath !== undefined, "There should be a package.json in hardhat-core's root directory" ); @@ -60,7 +60,7 @@ export function getProjectPackageJson(): Promise { const packageJsonPath = findup.sync("package.json"); assertHardhatInvariant( - packageJsonPath !== null, + packageJsonPath !== undefined, "Expected a package.json file in the current directory or in an ancestor directory" ); diff --git a/packages/hardhat-core/test/builtin-tasks/flatten.ts b/packages/hardhat-core/test/builtin-tasks/flatten.ts index 75cd7dbbc3..64844b5645 100644 --- a/packages/hardhat-core/test/builtin-tasks/flatten.ts +++ b/packages/hardhat-core/test/builtin-tasks/flatten.ts @@ -2,7 +2,7 @@ import { assert } from "chai"; import fs from "fs"; import sinon, { SinonSpy } from "sinon"; -import chalk from "chalk"; +import picocolors from "picocolors"; import { TASK_FLATTEN, TASK_FLATTEN_GET_FLATTENED_SOURCE, @@ -381,7 +381,7 @@ describe("Flatten task", () => { assert( spyFunctionConsoleWarn.calledWith( - chalk.yellow( + picocolors.yellow( `\nThe following file(s) do NOT specify SPDX licenses: contracts/A.sol, contracts/B.sol, contracts/C.sol` ) ) @@ -389,7 +389,7 @@ describe("Flatten task", () => { assert( spyFunctionConsoleWarn.calledWith( - chalk.yellow( + picocolors.yellow( `\nPragma abicoder directives are defined in some files, but they are not defined in the following ones: contracts/A.sol, contracts/B.sol` ) ) @@ -397,7 +397,7 @@ describe("Flatten task", () => { assert( spyFunctionConsoleWarn.calledWith( - chalk.yellow( + picocolors.yellow( `\nThe flattened file is using the pragma abicoder directive 'pragma abicoder v2' but these files have a different pragma abicoder directive: contracts/C.sol` ) ) diff --git a/packages/hardhat-core/test/internal/cli/vars/vars.ts b/packages/hardhat-core/test/internal/cli/vars/vars.ts index ba83c1d1bc..3ef44c4b4e 100644 --- a/packages/hardhat-core/test/internal/cli/vars/vars.ts +++ b/packages/hardhat-core/test/internal/cli/vars/vars.ts @@ -5,7 +5,7 @@ import fs from "fs-extra"; import * as os from "os"; import sinon, { SinonSandbox } from "sinon"; import { assert, expect } from "chai"; -import chalk from "chalk"; +import picocolors from "picocolors"; import enquirer from "enquirer"; import { HardhatContext } from "../../../../src/internal/context"; import { handleVars } from "../../../../src/internal/cli/vars"; @@ -149,7 +149,7 @@ describe("vars", () => { assert( spyConsoleWarn.calledWith( - chalk.yellow( + picocolors.yellow( `The configuration variable 'nonExistingKey' is not set in ${TMP_FILE_PATH}` ) ) @@ -194,7 +194,7 @@ describe("vars", () => { if (process.stdout.isTTY) { assert( spyConsoleWarn.calledWith( - chalk.yellow( + picocolors.yellow( `There are no configuration variables stored in ${TMP_FILE_PATH}` ) ) @@ -227,7 +227,7 @@ describe("vars", () => { ); assert( spyConsoleWarn.calledWith( - chalk.yellow( + picocolors.yellow( `There is no configuration variable 'nonExistingKey' to delete from ${TMP_FILE_PATH}` ) ) @@ -373,7 +373,7 @@ describe("vars", () => { assert( spyConsoleError.calledWith( - chalk.red( + picocolors.red( "There is an error in your Hardhat configuration file. Please double check it.\n" ) ) diff --git a/packages/hardhat-core/test/internal/sentry/anonymizer.ts b/packages/hardhat-core/test/internal/sentry/anonymizer.ts index 5f46a79ad9..cfad9f67e2 100644 --- a/packages/hardhat-core/test/internal/sentry/anonymizer.ts +++ b/packages/hardhat-core/test/internal/sentry/anonymizer.ts @@ -6,9 +6,9 @@ import { Anonymizer } from "../../../src/internal/sentry/anonymizer"; const PROJECT_ROOT = "/path/to/project"; class MockedAnonymizer extends Anonymizer { - public getFilePackageJsonPathResult: string | null = null; + public getFilePackageJsonPathResult: string | undefined = undefined; - protected _getFilePackageJsonPath(_: string): string | null { + protected _getFilePackageJsonPath(_: string): string | undefined { return this.getFilePackageJsonPathResult; } } diff --git a/packages/hardhat-core/test/setup.ts b/packages/hardhat-core/test/setup.ts index b07c382945..81acbf397f 100644 --- a/packages/hardhat-core/test/setup.ts +++ b/packages/hardhat-core/test/setup.ts @@ -1,6 +1,6 @@ import chai from "chai"; import chaiAsPromised from "chai-as-promised"; -import chalk from "chalk"; +import picocolors from "picocolors"; chai.use(chaiAsPromised); @@ -20,7 +20,7 @@ export const ALCHEMY_URL = getEnv("ALCHEMY_URL"); function printForkingLogicNotBeingTestedWarning(varName: string) { console.warn( - chalk.yellow( + picocolors.yellow( `TEST RUN INCOMPLETE: You need to define the env variable ${varName}` ) ); diff --git a/packages/hardhat-ethers/package.json b/packages/hardhat-ethers/package.json index 9118691669..62a0ea4b72 100644 --- a/packages/hardhat-ethers/package.json +++ b/packages/hardhat-ethers/package.json @@ -56,7 +56,6 @@ "@typescript-eslint/parser": "5.61.0", "chai": "^4.2.0", "chai-as-promised": "^7.1.1", - "chalk": "^2.4.2", "eslint": "^8.44.0", "eslint-config-prettier": "8.3.0", "eslint-plugin-import": "2.27.5", @@ -65,6 +64,7 @@ "ethers": "^6.1.0", "hardhat": "workspace:^2.0.0", "mocha": "^10.0.0", + "picocolors": "^1.1.0", "prettier": "2.4.1", "rimraf": "^3.0.2", "sinon": "^9.0.0", diff --git a/packages/hardhat-ethers/test/environment.ts b/packages/hardhat-ethers/test/environment.ts index 7e5c760d56..f3e90df9a5 100644 --- a/packages/hardhat-ethers/test/environment.ts +++ b/packages/hardhat-ethers/test/environment.ts @@ -1,4 +1,4 @@ -import chalk from "chalk"; +import picocolors from "picocolors"; import fs from "fs"; import { HardhatRuntimeEnvironment, HardhatUserConfig } from "hardhat/types"; import { resetHardhatContext } from "hardhat/plugins-testing"; @@ -39,7 +39,10 @@ export function useEnvironment( afterEach(function () { if (this.currentTest?.state === "failed") { - console.log(chalk.red("Failed in fixture project", fixtureProjectPath)); + console.log( + picocolors.red("Failed in fixture project"), + picocolors.red(fixtureProjectPath) + ); } }); } @@ -70,7 +73,10 @@ export function usePersistentEnvironment( afterEach(function () { if (this.currentTest?.state === "failed") { - console.log(chalk.red("Failed in fixture project", fixtureProjectPath)); + console.log( + picocolors.red("Failed in fixture project"), + picocolors.red(fixtureProjectPath) + ); } }); } @@ -159,7 +165,10 @@ contract Example { afterEach(function () { if (this.currentTest?.state === "failed") { - console.log(chalk.red("Failed in fixture project", fixtureProjectPath)); + console.log( + picocolors.red("Failed in fixture project"), + picocolors.red(fixtureProjectPath) + ); } }); } diff --git a/packages/hardhat-foundry/package.json b/packages/hardhat-foundry/package.json index ce87dd83c7..72c7340be1 100644 --- a/packages/hardhat-foundry/package.json +++ b/packages/hardhat-foundry/package.json @@ -32,9 +32,6 @@ "LICENSE", "README.md" ], - "dependencies": { - "chalk": "^2.4.2" - }, "devDependencies": { "@nomicfoundation/eslint-plugin-hardhat-internal-rules": "workspace:^", "@nomicfoundation/eslint-plugin-slow-imports": "workspace:^", @@ -58,5 +55,8 @@ }, "peerDependencies": { "hardhat": "workspace:^2.17.2" + }, + "dependencies": { + "picocolors": "^1.1.0" } } diff --git a/packages/hardhat-foundry/src/foundry.ts b/packages/hardhat-foundry/src/foundry.ts index c3fbf10350..77de6c275a 100644 --- a/packages/hardhat-foundry/src/foundry.ts +++ b/packages/hardhat-foundry/src/foundry.ts @@ -1,4 +1,4 @@ -import chalk from "chalk"; +import picocolors from "picocolors"; import { exec as execCallback, execSync } from "child_process"; import { NomicLabsHardhatPluginError } from "hardhat/internal/core/errors"; import { promisify } from "util"; @@ -75,7 +75,7 @@ export async function getRemappings() { export async function installDependency(dependency: string) { const cmd = `forge install --no-commit ${dependency}`; - console.log(`Running '${chalk.blue(cmd)}'`); + console.log(`Running '${picocolors.blue(cmd)}'`); try { await exec(cmd); diff --git a/packages/hardhat-foundry/src/index.ts b/packages/hardhat-foundry/src/index.ts index 8098279e35..68d1b061ae 100644 --- a/packages/hardhat-foundry/src/index.ts +++ b/packages/hardhat-foundry/src/index.ts @@ -7,7 +7,7 @@ import { import { HardhatRuntimeEnvironment } from "hardhat/types"; import { existsSync, writeFileSync } from "fs"; import path from "path"; -import chalk from "chalk"; +import picocolors from "picocolors"; import { getForgeConfig, getRemappings, @@ -24,7 +24,7 @@ extendConfig((config, userConfig) => { if (!existsSync(path.join(config.paths.root, "foundry.toml"))) { if (!process.argv.includes(TASK_INIT_FOUNDRY)) { console.log( - chalk.yellow( + picocolors.yellow( `Warning: You are using the hardhat-foundry plugin but there isn't a foundry.toml file in your project. Run 'npx hardhat ${TASK_INIT_FOUNDRY}' to create one.` ) ); @@ -112,7 +112,9 @@ task( ); if (existsSync(foundryConfigPath)) { - console.warn(chalk.yellow(`File foundry.toml already exists. Aborting.`)); + console.warn( + picocolors.yellow(`File foundry.toml already exists. Aborting.`) + ); process.exit(1); } diff --git a/packages/hardhat-verify/package.json b/packages/hardhat-verify/package.json index 409f97e97f..7eb30e89c7 100644 --- a/packages/hardhat-verify/package.json +++ b/packages/hardhat-verify/package.json @@ -42,9 +42,9 @@ "@ethersproject/abi": "^5.1.2", "@ethersproject/address": "^5.0.2", "cbor": "^8.1.0", - "chalk": "^2.4.2", "debug": "^4.1.1", "lodash.clonedeep": "^4.5.0", + "picocolors": "^1.1.0", "semver": "^6.3.0", "table": "^6.8.0", "undici": "^5.14.0" diff --git a/packages/hardhat-verify/src/index.ts b/packages/hardhat-verify/src/index.ts index 175ba72cb9..30cdae4e6f 100644 --- a/packages/hardhat-verify/src/index.ts +++ b/packages/hardhat-verify/src/index.ts @@ -5,7 +5,7 @@ import type { } from "./internal/solc/artifacts"; import type { Bytecode } from "./internal/solc/bytecode"; -import chalk from "chalk"; +import picocolors from "picocolors"; import { extendConfig, subtask, task, types } from "hardhat/config"; import { @@ -197,7 +197,7 @@ subtask( !config.blockscout.enabled ) { console.warn( - chalk.yellow( + picocolors.yellow( `[WARNING] No verification services are enabled. Please enable at least one verification service in your configuration.` ) ); diff --git a/packages/hardhat-verify/src/internal/config.ts b/packages/hardhat-verify/src/internal/config.ts index 58354c51be..21f0b7cd93 100644 --- a/packages/hardhat-verify/src/internal/config.ts +++ b/packages/hardhat-verify/src/internal/config.ts @@ -6,7 +6,7 @@ import type { BlockscoutConfig, } from "../types"; -import chalk from "chalk"; +import picocolors from "picocolors"; export function etherscanConfigExtender( config: HardhatConfig, @@ -28,7 +28,7 @@ export function etherscanConfigExtender( config.networks?.etherscan !== undefined ) { console.warn( - chalk.yellow( + picocolors.yellow( "WARNING: you have an 'etherscan' entry in your networks configuration. This is likely a mistake. The etherscan configuration should be at the root of the configuration, not within the networks object." ) ); diff --git a/packages/hardhat-verify/src/internal/tasks/sourcify.ts b/packages/hardhat-verify/src/internal/tasks/sourcify.ts index 02accba930..03facb6061 100644 --- a/packages/hardhat-verify/src/internal/tasks/sourcify.ts +++ b/packages/hardhat-verify/src/internal/tasks/sourcify.ts @@ -4,7 +4,7 @@ import type { LibraryToAddress, } from "../solc/artifacts"; -import chalk from "chalk"; +import picocolors from "picocolors"; import { subtask, types } from "hardhat/config"; import { isFullyQualifiedName } from "hardhat/utils/contract-names"; import { HARDHAT_NETWORK_NAME } from "hardhat/plugins"; @@ -224,7 +224,7 @@ ${contractURL} subtask(TASK_VERIFY_SOURCIFY_DISABLED_WARNING, async () => { console.info( - chalk.cyan( + picocolors.cyan( `[INFO] Sourcify Verification Skipped: Sourcify verification is currently disabled. To enable it, add the following entry to your Hardhat configuration: sourcify: { diff --git a/packages/hardhat-verify/src/internal/utilities.ts b/packages/hardhat-verify/src/internal/utilities.ts index 9785344b00..ea88f2863f 100644 --- a/packages/hardhat-verify/src/internal/utilities.ts +++ b/packages/hardhat-verify/src/internal/utilities.ts @@ -2,7 +2,7 @@ import type { JsonFragment } from "@ethersproject/abi"; import type { SolidityConfig } from "hardhat/types"; import type { ChainConfig } from "../types"; -import chalk from "chalk"; +import picocolors from "picocolors"; import path from "path"; import { builtinChains } from "./chain-config"; import { @@ -45,7 +45,7 @@ export async function printSupportedNetworks( ]); const supportedNetworksTable = table([ - [chalk.bold("network"), chalk.bold("chain id")], + [picocolors.bold("network"), picocolors.bold("chain id")], ...supportedNetworks, ]); @@ -58,7 +58,7 @@ export async function printSupportedNetworks( const customNetworksTable = customNetworks.length > 0 ? table([ - [chalk.bold("network"), chalk.bold("chain id")], + [picocolors.bold("network"), picocolors.bold("chain id")], ...customNetworks, ]) : table([["No custom networks were added"]]); @@ -85,7 +85,7 @@ To learn how to add custom networks, follow these instructions: https://hardhat. * are the names of verification subtasks and the values are HardhatVerifyError * objects describing the specific errors. * @remarks This function formats and logs the verification errors to the - * console with a red color using chalk. Each error is displayed along with the + * console with a red color using picocolors. Each error is displayed along with the * name of the verification provider it belongs to. * @example * const errors: Record = { @@ -119,7 +119,7 @@ export function printVerificationErrors( errorMessage += `${subtaskLabel}:\n${error.message}\n\n`; } - console.error(chalk.red(errorMessage)); + console.error(picocolors.red(errorMessage)); } /** diff --git a/packages/hardhat-verify/test/unit/utilities.ts b/packages/hardhat-verify/test/unit/utilities.ts index 8141002302..d82f0fb79d 100644 --- a/packages/hardhat-verify/test/unit/utilities.ts +++ b/packages/hardhat-verify/test/unit/utilities.ts @@ -5,7 +5,7 @@ import type { ChainConfig } from "../../src/types"; import path from "path"; import { assert, expect } from "chai"; import sinon from "sinon"; -import chalk from "chalk"; +import picocolors from "picocolors"; import { encodeArguments, @@ -65,7 +65,7 @@ describe("Utilities", () => { const errorMessage = errorStub.getCall(0).args[0]; assert.equal( errorMessage, - chalk.red( + picocolors.red( `hardhat-verify found one or more errors during the verification process: Etherscan: diff --git a/packages/hardhat-viem/package.json b/packages/hardhat-viem/package.json index a45bda1a2d..08dea7faf0 100644 --- a/packages/hardhat-viem/package.json +++ b/packages/hardhat-viem/package.json @@ -70,7 +70,6 @@ }, "peerDependencies": { "hardhat": "workspace:^2.17.0", - "typescript": "~5.0.0", "viem": "^2.7.6" }, "dependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9ecf43008b..8ff1e2faaa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -236,9 +236,6 @@ importers: boxen: specifier: ^5.1.2 version: 5.1.2 - chalk: - specifier: ^2.4.2 - version: 2.4.2 chokidar: specifier: ^4.0.0 version: 4.0.1 @@ -261,17 +258,14 @@ importers: specifier: ^0.6.8 version: 0.6.8 find-up: - specifier: ^2.1.0 - version: 2.1.0 + specifier: ^5.0.0 + version: 5.0.0 fp-ts: specifier: 1.19.3 version: 1.19.3 fs-extra: specifier: ^7.0.1 version: 7.0.1 - glob: - specifier: 7.2.0 - version: 7.2.0 immutable: specifier: ^4.0.0-rc.12 version: 4.3.7 @@ -296,6 +290,9 @@ importers: p-map: specifier: ^4.0.0 version: 4.0.0 + picocolors: + specifier: ^1.1.0 + version: 1.1.0 raw-body: specifier: ^2.4.1 version: 2.5.2 @@ -314,6 +311,9 @@ importers: stacktrace-parser: specifier: ^0.1.10 version: 0.1.10 + tinyglobby: + specifier: ^0.2.6 + version: 0.2.6 tsort: specifier: 0.0.1 version: 0.0.1 @@ -351,15 +351,9 @@ importers: '@types/debug': specifier: ^4.1.4 version: 4.1.12 - '@types/find-up': - specifier: ^2.1.1 - version: 2.1.1 '@types/fs-extra': specifier: ^5.1.0 version: 5.1.0 - '@types/glob': - specifier: ^7.1.1 - version: 7.2.0 '@types/keccak': specifier: ^3.0.1 version: 3.0.5 @@ -493,9 +487,6 @@ importers: chai-as-promised: specifier: ^7.1.1 version: 7.1.2(chai@4.5.0) - chalk: - specifier: ^2.4.2 - version: 2.4.2 eslint: specifier: ^8.44.0 version: 8.57.1 @@ -520,6 +511,9 @@ importers: mocha: specifier: ^10.0.0 version: 10.7.3 + picocolors: + specifier: ^1.1.0 + version: 1.1.0 prettier: specifier: 2.4.1 version: 2.4.1 @@ -538,9 +532,9 @@ importers: packages/hardhat-foundry: dependencies: - chalk: - specifier: ^2.4.2 - version: 2.4.2 + picocolors: + specifier: ^1.1.0 + version: 1.1.0 devDependencies: '@nomicfoundation/eslint-plugin-hardhat-internal-rules': specifier: workspace:^ @@ -1369,15 +1363,15 @@ importers: cbor: specifier: ^8.1.0 version: 8.1.0 - chalk: - specifier: ^2.4.2 - version: 2.4.2 debug: specifier: ^4.1.1 version: 4.3.7(supports-color@8.1.1) lodash.clonedeep: specifier: ^4.5.0 version: 4.5.0 + picocolors: + specifier: ^1.1.0 + version: 1.1.0 semver: specifier: ^6.3.0 version: 6.3.1 @@ -2675,9 +2669,6 @@ packages: '@types/events@3.0.3': resolution: {integrity: sha512-trOc4AAUThEz9hapPtSd7wf5tiQKvTtu5b371UxXdTuqzIh0ArcRspRP0i0Viu+LXstIQ1z96t1nsPxT9ol01g==} - '@types/find-up@2.1.1': - resolution: {integrity: sha512-60LC501bQRN9/3yfVaEEMd7IndaufffL56PBRAejPpUrY304Ps1jfnjNqPw5jmM5R8JHWiKBAe5IHzNcPV41AA==} - '@types/form-data@0.0.33': resolution: {integrity: sha512-8BSvG1kGm83cyJITQMZSulnl6QV8jqAGreJsc5tPu1Jq0vTSOiY/k24Wx82JRpWwZSqrala6sd5rWi6aNXvqcw==} @@ -4211,6 +4202,14 @@ packages: fastq@1.17.1: resolution: {integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==} + fdir@6.3.0: + resolution: {integrity: sha512-QOnuT+BOtivR77wYvCWHfGt9s4Pz1VIMbD463vegT5MLqNXy8rYFT/lPVEqf/bhYeT6qmqrNHhsX+rWwe3rOCQ==} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + file-entry-cache@6.0.1: resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} engines: {node: ^10.12.0 || >=12.0.0} @@ -4238,10 +4237,6 @@ packages: resolution: {integrity: sha512-jvElSjyuo4EMQGoTwo1uJU5pQMwTW5lS1x05zzfJuTIyLR3zwO27LYrxNg+dlvKpGOuGy/MzBdXh80g0ve5+HA==} engines: {node: '>=0.10.0'} - find-up@2.1.0: - resolution: {integrity: sha512-NWzkk0jSJtTt08+FBFMvXoeZnOJD+jTtsRmBYbAIzJdX6l7dLgR7CTubCM5/eDdPUBvLCeVasP1brfVR/9/EZQ==} - engines: {node: '>=4'} - find-up@4.1.0: resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} engines: {node: '>=8'} @@ -5054,10 +5049,6 @@ packages: resolution: {integrity: sha512-cy7ZdNRXdablkXYNI049pthVeXFurRyb9+hA/dZzerZ0pGTx42z+y+ssxBaVV2l70t1muq5IdKhn4UtcoGUY9A==} engines: {node: '>=0.10.0'} - locate-path@2.0.0: - resolution: {integrity: sha512-NCI2kiDkyR7VeEKm27Kda/iQHyKJe1Bu0FlTbYp3CqJu+9IFe9bLyAjMxf5ZDDbEg+iMPzB5zYyUTSm8wVTKmA==} - engines: {node: '>=4'} - locate-path@5.0.0: resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} engines: {node: '>=8'} @@ -5517,10 +5508,6 @@ packages: resolution: {integrity: sha512-ZBxxZ5sL2HghephhpGAQdoskxplTwr7ICaehZwLIlfL6acuVgZPm8yBNuRAFBGEqtD/hmUeq9eqLg2ys9Xr/yw==} engines: {node: '>=8'} - p-limit@1.3.0: - resolution: {integrity: sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==} - engines: {node: '>=4'} - p-limit@2.3.0: resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} engines: {node: '>=6'} @@ -5529,10 +5516,6 @@ packages: resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} engines: {node: '>=10'} - p-locate@2.0.0: - resolution: {integrity: sha512-nQja7m7gSKuewoVRen45CtVfODR3crN3goVQ0DDZ9N3yHxgpkuBhZqsaiotSQRrADUrne346peY7kT3TSACykg==} - engines: {node: '>=4'} - p-locate@4.1.0: resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==} engines: {node: '>=8'} @@ -5553,10 +5536,6 @@ packages: resolution: {integrity: sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==} engines: {node: '>=10'} - p-try@1.0.0: - resolution: {integrity: sha512-U1etNYuMJoIz3ZXSrrySFjsXQTWOx2/jdi86L+2pRvph/qMKL6sbcCYdH23fqsbm8TH2Gn0OybpT4eSFlCVHww==} - engines: {node: '>=4'} - p-try@2.2.0: resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} engines: {node: '>=6'} @@ -5623,10 +5602,6 @@ packages: resolution: {integrity: sha512-yTltuKuhtNeFJKa1PiRzfLAU5182q1y4Eb4XCJ3PBqyzEDkAZRzBrKKBct682ls9reBVHf9udYLN5Nd+K1B9BQ==} engines: {node: '>=0.10.0'} - path-exists@3.0.0: - resolution: {integrity: sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==} - engines: {node: '>=4'} - path-exists@4.0.0: resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} engines: {node: '>=8'} @@ -5666,6 +5641,9 @@ packages: performance-now@2.1.0: resolution: {integrity: sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==} + picocolors@1.1.0: + resolution: {integrity: sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==} + picocolors@1.1.1: resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} @@ -5673,6 +5651,10 @@ packages: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} + picomatch@4.0.2: + resolution: {integrity: sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==} + engines: {node: '>=12'} + pify@2.3.0: resolution: {integrity: sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==} engines: {node: '>=0.10.0'} @@ -6396,6 +6378,10 @@ packages: resolution: {integrity: sha512-G7r3AhovYtr5YKOWQkta8RKAPb+J9IsO4uVmzjl8AZwfhs8UcUwTiD6gcJYSgOtzyjvQKrKYn41syHbUWMkafA==} engines: {node: '>=0.10.0'} + tinyglobby@0.2.6: + resolution: {integrity: sha512-NbBoFBpqfcgd1tCiO8Lkfdk+xrA7mlLR9zgvZcZWQQwU63XAfUePyd6wZBaU93Hqw347lHnwFzttAkemHzzz4g==} + engines: {node: '>=12.0.0'} + title-case@2.1.1: resolution: {integrity: sha512-EkJoZ2O3zdCz3zJsYCsxyq2OC5hrxR9mfdd5I+w8h/tmFfeOxJ+vvkxsKxdmN0WtS9zLdHEgfgVOiMVgv+Po4Q==} @@ -8507,8 +8493,6 @@ snapshots: '@types/events@3.0.3': {} - '@types/find-up@2.1.1': {} - '@types/form-data@0.0.33': dependencies: '@types/node': 18.19.59 @@ -10400,6 +10384,10 @@ snapshots: dependencies: reusify: 1.0.4 + fdir@6.3.0(picomatch@4.0.2): + optionalDependencies: + picomatch: 4.0.2 + file-entry-cache@6.0.1: dependencies: flat-cache: 3.2.0 @@ -10437,10 +10425,6 @@ snapshots: path-exists: 2.1.0 pinkie-promise: 2.0.1 - find-up@2.1.0: - dependencies: - locate-path: 2.0.0 - find-up@4.1.0: dependencies: locate-path: 5.0.0 @@ -11297,11 +11281,6 @@ snapshots: pinkie-promise: 2.0.1 strip-bom: 2.0.0 - locate-path@2.0.0: - dependencies: - p-locate: 2.0.0 - path-exists: 3.0.0 - locate-path@5.0.0: dependencies: p-locate: 4.1.0 @@ -11764,10 +11743,6 @@ snapshots: dependencies: p-map: 2.1.0 - p-limit@1.3.0: - dependencies: - p-try: 1.0.0 - p-limit@2.3.0: dependencies: p-try: 2.2.0 @@ -11776,10 +11751,6 @@ snapshots: dependencies: yocto-queue: 0.1.0 - p-locate@2.0.0: - dependencies: - p-limit: 1.3.0 - p-locate@4.1.0: dependencies: p-limit: 2.3.0 @@ -11798,8 +11769,6 @@ snapshots: dependencies: aggregate-error: 3.1.0 - p-try@1.0.0: {} - p-try@2.2.0: {} package-hash@4.0.0: @@ -11873,8 +11842,6 @@ snapshots: dependencies: pinkie-promise: 2.0.1 - path-exists@3.0.0: {} - path-exists@4.0.0: {} path-is-absolute@1.0.1: {} @@ -11909,10 +11876,14 @@ snapshots: performance-now@2.1.0: {} + picocolors@1.1.0: {} + picocolors@1.1.1: {} picomatch@2.3.1: {} + picomatch@4.0.2: {} + pify@2.3.0: {} pify@4.0.1: {} @@ -12810,6 +12781,11 @@ snapshots: timed-out@4.0.1: {} + tinyglobby@0.2.6: + dependencies: + fdir: 6.3.0(picomatch@4.0.2) + picomatch: 4.0.2 + title-case@2.1.1: dependencies: no-case: 2.3.2