Skip to content

Commit 84a93d6

Browse files
committed
Give more guidance when using elm-review init with --template
Fixes #139
1 parent fb97d74 commit 84a93d6

File tree

2 files changed

+48
-11
lines changed

2 files changed

+48
-11
lines changed

lib/init.js

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,29 +79,51 @@ async function createFromTemplate(options, template, directory) {
7979
}
8080

8181
function logInit(options, directory) {
82+
const message = options.template
83+
? templateInitMessage(options, directory)
84+
: regularInitMessage(options, directory);
85+
8286
console.log(
8387
`All done! I have created a review project at ${chalk.green(
8488
(Anonymize.path(options, directory) + '/').replace(/\/\//g, '/')
85-
)} for you.`
86-
);
89+
)} for you.
8790
88-
if (!options.template) {
89-
console.log(`
90-
You can now define your review configuration by editing ${chalk.green(
91-
Anonymize.path(options, path.join(directory, 'src/ReviewConfig.elm'))
92-
)}.
91+
${message}
9392
9493
I recommend you take a look at the following documents:
9594
- How to configure ${chalk.cyan('elm-review')}: ${chalk.underline(
9695
'https://github.com/jfmengels/elm-review/#Configuration'
9796
)}
9897
- When to write or enable a rule: ${chalk.underline(
99-
'https://github.com/jfmengels/elm-review/#when-to-write-or-enable-a-rule'
100-
)}
101-
`);
102-
}
98+
'https://github.com/jfmengels/elm-review/#when-to-write-or-enable-a-rule'
99+
)}
100+
${options.template ? templateRecommendation : ''}`);
101+
}
102+
103+
function regularInitMessage(options, directory) {
104+
return `You can now define your review configuration by editing ${chalk.green(
105+
Anonymize.path(options, path.join(directory, 'src/ReviewConfig.elm'))
106+
)}.`
103107
}
104108

109+
const orange = chalk.keyword('orange');
110+
111+
function templateInitMessage(options, directory) {
112+
return `You chose to use someone's review configuration which can be great to get started
113+
but don't forget to review the configuration to make sure it fits your needs,
114+
both by removing rules you disagree with and by finding new rules to aid you.
115+
You can do so by editing ${chalk.green(
116+
Anonymize.path(options, path.join(directory, 'src/ReviewConfig.elm'))
117+
)}.`
118+
}
119+
120+
const templateRecommendation = `
121+
By starting out with this configuration, you may end up with too many errors to handle at once.
122+
I recommend you use a mix of the following approaches:
123+
- Enable rules one by one by commenting them out at first
124+
- Use ${orange('elm-review suppress')} to suppress existing errors but prevent future ones (see ${orange('elm-review suppress --help')}).
125+
`
126+
105127
async function create(options, directory, template) {
106128
const configDirectory = path.join(directory, 'src');
107129

test/run-snapshots/init-template.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
11
All done! I have created a review project at review/ for you.
2+
3+
You chose to use someone's review configuration which can be great to get started
4+
but don't forget to review the configuration to make sure it fits your needs,
5+
both by removing rules you disagree with and by finding new rules to aid you.
6+
You can do so by editing review/src/ReviewConfig.elm.
7+
8+
I recommend you take a look at the following documents:
9+
- How to configure elm-review: https://github.com/jfmengels/elm-review/#Configuration
10+
- When to write or enable a rule: https://github.com/jfmengels/elm-review/#when-to-write-or-enable-a-rule
11+
12+
By starting out with this configuration, you may end up with too many errors to handle at once.
13+
I recommend you use a mix of the following approaches:
14+
- Enable rules one by one by commenting them out at first
15+
- Use elm-review suppress to suppress existing errors but prevent future ones (see elm-review suppress --help).
16+

0 commit comments

Comments
 (0)