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

Give more guidance when using elm-review init with --template #141

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

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

Loading