From d73e842d2faa821cd893f14222dcb1b21e3b6bea Mon Sep 17 00:00:00 2001 From: Alexandre Bodin Date: Tue, 29 Oct 2019 08:54:46 +0100 Subject: [PATCH] Improve the error message on install dependencies error in create strapi-app --- .../strapi-generate-new/lib/create-project.js | 21 ++++++++++++++++++- .../lib/utils/stop-process.js | 2 +- packages/strapi-generate-new/package.json | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/strapi-generate-new/lib/create-project.js b/packages/strapi-generate-new/lib/create-project.js index 2eb9ccf6b13..0197c24c2d9 100644 --- a/packages/strapi-generate-new/lib/create-project.js +++ b/packages/strapi-generate-new/lib/create-project.js @@ -105,7 +105,26 @@ module.exports = async function createProject( await captureStderr('didNotInstallProjectDependencies', error); - stopProcess('Stopping installation'); + console.log(chalk.black.bgWhite(' Keep trying! ')); + console.log(); + console.log( + chalk.bold( + 'Oh, it seems that you encountered errors while installing dependencies in your project.' + ) + ); + console.log(`Don't give up, your project was created correctly.`); + console.log( + `Fix the issues mentionned in the installation errors and try to run the following command:` + ); + console.log(); + console.log( + `cd ${chalk.green(rootPath)} && ${chalk.cyan( + scope.useYarn ? 'yarn' : 'npm' + )} install` + ); + console.log(); + + stopProcess(); } await trackUsage({ event: 'didCreateProject', scope }); diff --git a/packages/strapi-generate-new/lib/utils/stop-process.js b/packages/strapi-generate-new/lib/utils/stop-process.js index 884cc01431d..78010c97369 100644 --- a/packages/strapi-generate-new/lib/utils/stop-process.js +++ b/packages/strapi-generate-new/lib/utils/stop-process.js @@ -1,6 +1,6 @@ 'use strict'; module.exports = function stopProcess(message) { - console.error(message); + if (message) console.error(message); process.exit(1); }; diff --git a/packages/strapi-generate-new/package.json b/packages/strapi-generate-new/package.json index 219fc2778a9..dbc6e3dff82 100644 --- a/packages/strapi-generate-new/package.json +++ b/packages/strapi-generate-new/package.json @@ -14,6 +14,7 @@ }, "dependencies": { "@sentry/node": "^5.7.1", + "chalk": "^2.4.2", "execa": "^1.0.0", "fs-extra": "^8.0.1", "inquirer": "^6.3.1",