diff --git a/.changeset/shaggy-experts-fetch.md b/.changeset/shaggy-experts-fetch.md new file mode 100644 index 0000000000..5386d66f6e --- /dev/null +++ b/.changeset/shaggy-experts-fetch.md @@ -0,0 +1,5 @@ +--- +"hardhat": patch +--- + +Show a message with a link to the Solidity Developer Survey diff --git a/docs/redirects.config.js b/docs/redirects.config.js index f33ccb12a4..c2ce1aa690 100644 --- a/docs/redirects.config.js +++ b/docs/redirects.config.js @@ -86,6 +86,11 @@ const customRedirects = [ destination: "/hardhat-network/docs/guides/forking-other-networks.html#using-a-custom-hardfork-history", permanent: false }, + { + source: "/solidity-survey-2022", + destination: "https://cryptpad.fr/form/#/2/form/view/HuPIRv4gvziSV0dPV1SJncKzYJXTVc8LGCaMfLUoj2c/", + permanent: false + }, // top-level component URLs { diff --git a/packages/hardhat-core/src/internal/cli/cli.ts b/packages/hardhat-core/src/internal/cli/cli.ts index a6566329a2..12d9ffc3f9 100755 --- a/packages/hardhat-core/src/internal/cli/cli.ts +++ b/packages/hardhat-core/src/internal/cli/cli.ts @@ -39,7 +39,7 @@ import { saveFlamegraph } from "../core/flamegraph"; import { Analytics } from "./analytics"; import { ArgumentsParser } from "./ArgumentsParser"; import { enableEmoji } from "./emoji"; -import { createProject } from "./project-creation"; +import { createProject, showSoliditySurveyMessage } from "./project-creation"; import { confirmHHVSCodeInstallation, confirmTelemetryConsent } from "./prompt"; import { InstallationState, @@ -301,6 +301,16 @@ async function main() { process.stdout.isTTY === true ) { await suggestInstallingHardhatVscode(); + + // we show the solidity survey message if the tests failed and only + // 1/3 of the time + if ( + process.exitCode !== 0 && + Math.random() < 0.3333 && + process.env.HARDHAT_HIDE_SOLIDITY_SURVEY_MESSAGE !== "true" + ) { + showSoliditySurveyMessage(); + } } log(`Killing Hardhat after successfully running task ${taskName}`); diff --git a/packages/hardhat-core/src/internal/cli/project-creation.ts b/packages/hardhat-core/src/internal/cli/project-creation.ts index e5228e07d0..482f85a154 100644 --- a/packages/hardhat-core/src/internal/cli/project-creation.ts +++ b/packages/hardhat-core/src/internal/cli/project-creation.ts @@ -252,6 +252,20 @@ function showStarOnGitHubMessage() { console.log(chalk.cyan(" https://github.com/NomicFoundation/hardhat")); } +export function showSoliditySurveyMessage() { + if (new Date() > new Date("2023-07-01 23:39")) { + // the survey has finished + return; + } + + console.log(); + console.log( + chalk.cyan( + "Please take a moment to complete the 2022 Solidity Survey: https://hardhat.org/solidity-survey-2022" + ) + ); +} + export async function createProject() { printAsciiLogo(); @@ -287,6 +301,7 @@ export async function createProject() { console.log(); showStarOnGitHubMessage(); + showSoliditySurveyMessage(); return; } @@ -387,6 +402,7 @@ export async function createProject() { console.log("See the README.md file for some example tasks you can run"); console.log(); showStarOnGitHubMessage(); + showSoliditySurveyMessage(); } async function canInstallRecommendedDeps() {