Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show solidity survey message #3405

Merged
merged 2 commits into from Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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