From bd2450a2d9db76e0dd0b1335179e5772fa321554 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Fri, 15 Sep 2023 18:44:05 +0200 Subject: [PATCH] Give more guidance when using elm-review init with --template Fixes #139 --- CHANGELOG.md | 2 ++ lib/init.js | 45 ++++++++++++++++++++++------ test/run-snapshots/init-template.txt | 15 ++++++++++ 3 files changed, 53 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d3e27e5e..05e749268 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [Unreleased] +- Improved guidance after using `elm-review init --template ` + ## [2.10.2] - 2023-05-05 Replace some npm dependencies. diff --git a/lib/init.js b/lib/init.js index 00282752c..c93ffa585 100644 --- a/lib/init.js +++ b/lib/init.js @@ -79,17 +79,16 @@ async function createFromTemplate(options, template, directory) { } function logInit(options, directory) { + const message = options.template + ? templateInitMessage(options, directory) + : regularInitMessage(options, directory); + console.log( `All done! I have created a review project at ${chalk.green( (Anonymize.path(options, directory) + '/').replace(/\/\//g, '/') - )} for you.` - ); + )} for you. - if (!options.template) { - console.log(` -You can now define your review configuration by editing ${chalk.green( - Anonymize.path(options, path.join(directory, 'src/ReviewConfig.elm')) - )}. +${message} I recommend you take a look at the following documents: - How to configure ${chalk.cyan('elm-review')}: ${chalk.underline( @@ -98,10 +97,38 @@ I recommend you take a look at the following documents: - When to write or enable a rule: ${chalk.underline( 'https://github.com/jfmengels/elm-review/#when-to-write-or-enable-a-rule' )} -`); - } +${options.template ? templateRecommendation : ''}` + ); +} + +function regularInitMessage(options, directory) { + return `You can now define your review configuration by editing ${chalk.green( + Anonymize.path(options, path.join(directory, 'src/ReviewConfig.elm')) + )}.`; } +const orange = chalk.keyword('orange'); + +function templateInitMessage(options, directory) { + return `You chose to use someone's review configuration which can be great to get started +but don't forget to review the configuration to make sure it fits your needs, +both by removing rules you disagree with and by finding new rules to aid you. +You can do so by editing ${chalk.green( + Anonymize.path(options, path.join(directory, 'src/ReviewConfig.elm')) + )}.`; +} + +const templateRecommendation = ` +By starting out with this configuration, you may end up with too many errors to handle at once. +I recommend you use a mix of the following approaches: + - Enable rules one by one by commenting them out at first + - Use ${orange( + 'elm-review suppress' + )} to suppress existing errors but prevent future ones (see ${orange( + 'elm-review suppress --help' +)}). +`; + async function create(options, directory, template) { const configDirectory = path.join(directory, 'src'); diff --git a/test/run-snapshots/init-template.txt b/test/run-snapshots/init-template.txt index 161c71ff6..c328ea2cf 100644 --- a/test/run-snapshots/init-template.txt +++ b/test/run-snapshots/init-template.txt @@ -1 +1,16 @@ All done! I have created a review project at review/ for you. + +You chose to use someone's review configuration which can be great to get started +but don't forget to review the configuration to make sure it fits your needs, +both by removing rules you disagree with and by finding new rules to aid you. +You can do so by editing review/src/ReviewConfig.elm. + +I recommend you take a look at the following documents: + - How to configure elm-review: https://github.com/jfmengels/elm-review/#Configuration + - When to write or enable a rule: https://github.com/jfmengels/elm-review/#when-to-write-or-enable-a-rule + +By starting out with this configuration, you may end up with too many errors to handle at once. +I recommend you use a mix of the following approaches: + - Enable rules one by one by commenting them out at first + - Use elm-review suppress to suppress existing errors but prevent future ones (see elm-review suppress --help). +