Skip to content

Commit

Permalink
Rename chalk to picocolors
Browse files Browse the repository at this point in the history
  • Loading branch information
alcuadrado committed Oct 26, 2024
1 parent c75614a commit 58cc0a3
Show file tree
Hide file tree
Showing 18 changed files with 102 additions and 88 deletions.
10 changes: 6 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 "picocolors";
import picocolors from "picocolors";
import debug from "debug";
import fsExtra from "fs-extra";
import semver from "semver";
Expand Down Expand Up @@ -801,12 +801,14 @@ subtask(TASK_COMPILE_SOLIDITY_LOG_COMPILATION_ERRORS)
error.formattedMessage;

console.error(
errorMessage.replace(/^\w+:/, (t) => chalk.bold(chalk.red(t)))
errorMessage.replace(/^\w+:/, (t) =>
picocolors.bold(picocolors.red(t))
)
);
} else {
console.warn(
(error.formattedMessage as string).replace(/^\w+:/, (t) =>
chalk.bold(chalk.yellow(t))
picocolors.bold(picocolors.yellow(t))
)
);
}
Expand All @@ -815,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 "picocolors";
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 "picocolors";
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 "picocolors";
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 "picocolors";
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
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 "picocolors";
import picocolors from "picocolors";

import { isNodeVersionToWarnOn } from "./is-node-version-to-warn-on";

if (isNodeVersionToWarnOn(process.version)) {
console.warn(
chalk.yellow(chalk.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: 16 additions & 14 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 "picocolors";
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,15 +170,15 @@ async function main() {

// Warning for Hardhat V3 deprecation
console.warn(
chalk.yellow(chalk.bold("\n\nDEPRECATION WARNING\n\n")),
chalk.yellow(
`Initializing a project with ${chalk.white(
chalk.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(
chalk.italic("npx hardhat init")
picocolors.yellow(
`Please use ${picocolors.white(
picocolors.italic("npx hardhat init")
)} instead.\n\n`
)
);
Expand Down Expand Up @@ -389,20 +389,22 @@ async function main() {
if (HardhatError.isHardhatError(error)) {
isHardhatError = true;
console.error(
chalk.red(chalk.bold("Error")),
error.message.replace(/^\w+:/, (t) => chalk.red(chalk.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(chalk.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
44 changes: 27 additions & 17 deletions packages/hardhat-core/src/internal/cli/project-creation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from "picocolors";
import picocolors from "picocolors";
import fsExtra from "fs-extra";
import path from "path";

Expand Down Expand Up @@ -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("");
}
Expand All @@ -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`
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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() {
Expand All @@ -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"
)
);
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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"
)
);
}

Expand All @@ -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");
Expand Down
Loading

0 comments on commit 58cc0a3

Please sign in to comment.