Skip to content

Commit

Permalink
Merge pull request #5767 from talentlessguy/general-cleanup
Browse files Browse the repository at this point in the history
General dependency cleanup
  • Loading branch information
alcuadrado authored Oct 26, 2024
2 parents b41c9c7 + fcece65 commit ae69f10
Show file tree
Hide file tree
Showing 44 changed files with 242 additions and 220 deletions.
5 changes: 5 additions & 0 deletions .changeset/light-beds-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-foundry": patch
---

Replace chalk with picocolor
5 changes: 5 additions & 0 deletions .changeset/purple-starfishes-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-viem": patch
---

Remove unnecessary peerDependency
5 changes: 5 additions & 0 deletions .changeset/smart-rocks-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Replaced `chalk` with `picocolors`, `glob` with `tinyglob`, and upgraded `find-up`
5 changes: 5 additions & 0 deletions .changeset/unlucky-humans-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-verify": patch
---

Replace chalk with picocolors
2 changes: 1 addition & 1 deletion config/eslint/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports.slowImportsCommonIgnoredModules = [
"chalk",
"picocolors",
"debug",
"find-up",
"fs-extra",
Expand Down
8 changes: 3 additions & 5 deletions packages/hardhat-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -114,18 +112,16 @@
"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",
"enquirer": "^2.3.0",
"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",
Expand All @@ -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",
Expand Down
12 changes: 8 additions & 4 deletions packages/hardhat-core/src/builtin-tasks/compile.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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))
)
);
}
Expand All @@ -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.`
)
);
Expand Down
8 changes: 4 additions & 4 deletions packages/hardhat-core/src/builtin-tasks/flatten.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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(
", "
)}`
Expand All @@ -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(
", "
)}`
Expand All @@ -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(
Expand Down
10 changes: 5 additions & 5 deletions packages/hardhat-core/src/builtin-tasks/node.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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."
)
);
Expand Down Expand Up @@ -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}/`
)
);
Expand Down Expand Up @@ -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."
)
);
Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat-core/src/builtin-tasks/test.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat-core/src/builtin-tasks/utils/watch.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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."
)
);
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat-core/src/internal/cli/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat-core/src/internal/cli/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
30 changes: 17 additions & 13 deletions packages/hardhat-core/src/internal/cli/cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from "chalk";
import picocolors from "picocolors";
import debug from "debug";
import "source-map-support/register";

Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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`
)
);

Expand Down Expand Up @@ -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;
}

Expand Down
Loading

0 comments on commit ae69f10

Please sign in to comment.