Skip to content

Commit

Permalink
Show solidity survey message
Browse files Browse the repository at this point in the history
  • Loading branch information
fvictorio committed Dec 8, 2022
1 parent dd9c3dc commit a440261
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/redirects.config.js
Expand Up @@ -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
{
Expand Down
12 changes: 11 additions & 1 deletion packages/hardhat-core/src/internal/cli/cli.ts
Expand Up @@ -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,
Expand Down Expand Up @@ -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}`);
Expand Down
16 changes: 16 additions & 0 deletions packages/hardhat-core/src/internal/cli/project-creation.ts
Expand Up @@ -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();

Expand Down Expand Up @@ -287,6 +301,7 @@ export async function createProject() {

console.log();
showStarOnGitHubMessage();
showSoliditySurveyMessage();

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

0 comments on commit a440261

Please sign in to comment.