Skip to content

Commit

Permalink
Give more guidance when using elm-review init with --template
Browse files Browse the repository at this point in the history
Fixes #139
  • Loading branch information
jfmengels committed Sep 15, 2023
1 parent aa0ae17 commit bd2450a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Unreleased]

- Improved guidance after using `elm-review init --template <some-template>`

## [2.10.2] - 2023-05-05

Replace some npm dependencies.
Expand Down
45 changes: 36 additions & 9 deletions lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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');

Expand Down
15 changes: 15 additions & 0 deletions test/run-snapshots/init-template.txt
Original file line number Diff line number Diff line change
@@ -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).

0 comments on commit bd2450a

Please sign in to comment.