1
+ /**
2
+ * @import {Options, Template} from './types/options';
3
+ * @import {Path} from './types/path';
4
+ */
5
+
1
6
const path = require ( 'node:path' ) ;
2
7
const fs = require ( 'graceful-fs' ) ;
3
8
// TODO(@lishaduck) [engine:node@>=16.7.0]: Use native `cp`.
@@ -10,6 +15,10 @@ const RemoteTemplate = require('./remote-template');
10
15
const { getElmBinary, getElmVersion} = require ( './elm-binary' ) ;
11
16
const TemplateDependencies = require ( './template-dependencies' ) ;
12
17
18
+ /**
19
+ * @param {Options } options
20
+ * @returns {Promise<void> }
21
+ */
13
22
async function promptAndCreate ( options ) {
14
23
const directory = options . initPath ( ) ;
15
24
@@ -38,6 +47,11 @@ async function promptAndCreate(options) {
38
47
logInit ( options , directory ) ;
39
48
}
40
49
50
+ /**
51
+ * @param {Options } options
52
+ * @param {Template } template
53
+ * @param {string } directory
54
+ */
41
55
async function createFromTemplate ( options , template , directory ) {
42
56
const configDirectory = path . join ( directory , 'src' ) ;
43
57
@@ -73,6 +87,10 @@ async function createFromTemplate(options, template, directory) {
73
87
) ;
74
88
}
75
89
90
+ /**
91
+ * @param {Options } options
92
+ * @param {Path } directory
93
+ */
76
94
function logInit ( options , directory ) {
77
95
const message = options . template
78
96
? templateInitMessage ( options , directory )
@@ -96,6 +114,10 @@ ${options.template ? templateRecommendation : ''}`
96
114
) ;
97
115
}
98
116
117
+ /**
118
+ * @param {Options } options
119
+ * @param {Path } directory
120
+ */
99
121
function regularInitMessage ( options , directory ) {
100
122
return `You can now define your review configuration by editing ${ chalk . green (
101
123
Anonymize . path ( options , path . join ( directory , 'src/ReviewConfig.elm' ) )
@@ -104,6 +126,10 @@ function regularInitMessage(options, directory) {
104
126
105
127
const orange = chalk . keyword ( 'orange' ) ;
106
128
129
+ /**
130
+ * @param {Options } options
131
+ * @param {Path } directory
132
+ */
107
133
function templateInitMessage ( options , directory ) {
108
134
return `You chose to use someone's review configuration which can be great to get started
109
135
but don't forget to review the configuration to make sure it fits your needs,
@@ -124,6 +150,11 @@ I recommend you use a mix of the following approaches:
124
150
) } ).
125
151
` ;
126
152
153
+ /**
154
+ * @param {Options } options
155
+ * @param {Path } directory
156
+ * @param {string } template
157
+ */
127
158
async function create ( options , directory , template ) {
128
159
const configDirectory = path . join ( directory , 'src' ) ;
129
160
@@ -135,6 +166,10 @@ async function create(options, directory, template) {
135
166
createReviewConfig ( configDirectory , template ) ;
136
167
}
137
168
169
+ /**
170
+ * @param {Options } options
171
+ * @param {Path } directory
172
+ */
138
173
async function createElmJson ( options , directory ) {
139
174
const elmBinary = await getElmBinary ( options ) ;
140
175
const elmVersion = getElmVersion ( elmBinary ) ;
@@ -149,6 +184,10 @@ async function createElmJson(options, directory) {
149
184
) ;
150
185
}
151
186
187
+ /**
188
+ * @param {Path } directory
189
+ * @param {string } template
190
+ */
152
191
function createReviewConfig ( directory , template ) {
153
192
fsExtra . copyFileSync (
154
193
path . join ( __dirname , '../init-templates/' , template ) ,
0 commit comments