Skip to content

Commit

Permalink
Show the solidity survey message
Browse files Browse the repository at this point in the history
  • Loading branch information
fvictorio committed Dec 18, 2023
1 parent dc23aad commit e5f9f95
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
7 changes: 3 additions & 4 deletions docs/redirects.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,9 @@ const customRedirects = [
permanent: false,
},
{
source: "/solidity-survey-2022",
destination:
"https://cryptpad.fr/form/#/2/form/view/HuPIRv4gvziSV0dPV1SJncKzYJXTVc8LGCaMfLUoj2c/",
permanent: false,
source: "/solidity-survey-2023",
destination: "https://cryptpad.fr/form/#/2/form/view/pV-DdryeJoYUWvW+gXsFaMNynEY7t5mUsgeD1urgwSE",
permanent: false
},
{
source: "/solc-viair",
Expand Down
12 changes: 11 additions & 1 deletion packages/hardhat-core/src/internal/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,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 @@ -358,6 +358,16 @@ async function main() {
) {
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();
}

// we show the viaIR warning only if the tests failed
if (process.exitCode !== 0) {
showViaIRWarning(resolvedConfig);
Expand Down
16 changes: 16 additions & 0 deletions packages/hardhat-core/src/internal/cli/project-creation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,20 @@ function showStarOnGitHubMessage() {
console.log(chalk.cyan(" https://github.com/NomicFoundation/hardhat"));
}

export function showSoliditySurveyMessage() {
if (new Date() > new Date("2024-01-07 23:39")) {
// the survey has finished
return;
}

console.log();
console.log(
chalk.cyan(
"Please take a moment to complete the 2023 Solidity Survey: https://hardhat.org/solidity-survey-2023"
)
);
}

export async function createProject() {
printAsciiLogo();

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

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

return;
}
Expand Down Expand Up @@ -512,6 +527,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 e5f9f95

Please sign in to comment.