@@ -9,7 +9,7 @@ import any from '@travi/any';
9
9
import { when } from 'jest-when' ;
10
10
11
11
import { scaffold as liftGit , initialize as scaffoldGit } from './vcs/git/git.js' ;
12
- import * as vcsHostScaffolder from './vcs/host/scaffolder .js' ;
12
+ import { scaffold as scaffoldVcsHost } from './vcs/host/index .js' ;
13
13
import * as licenseScaffolder from './license/scaffolder.js' ;
14
14
import scaffoldLanguage from './language/scaffolder.js' ;
15
15
import * as languagePrompt from './language/prompt.js' ;
@@ -27,7 +27,7 @@ vi.mock('@form8ion/execa-wrapper');
27
27
vi . mock ( '@form8ion/results-reporter' ) ;
28
28
vi . mock ( './readme' ) ;
29
29
vi . mock ( './vcs/git/git.js' ) ;
30
- vi . mock ( './vcs/host/scaffolder ' ) ;
30
+ vi . mock ( './vcs/host/index.js ' ) ;
31
31
vi . mock ( './license/scaffolder' ) ;
32
32
vi . mock ( './language/scaffolder' ) ;
33
33
vi . mock ( './language/prompt' ) ;
@@ -53,6 +53,7 @@ describe('project scaffolder', () => {
53
53
const documentation = any . simpleObject ( ) ;
54
54
const vcs = any . simpleObject ( ) ;
55
55
const vcsOriginDetails = any . simpleObject ( ) ;
56
+ const vcsHostResults = { ...any . simpleObject ( ) , vcs : vcsOriginDetails } ;
56
57
const tags = any . listOf ( any . word ) ;
57
58
const visibility = any . word ( ) ;
58
59
const vcsIgnore = any . simpleObject ( ) ;
@@ -117,7 +118,7 @@ describe('project scaffolder', () => {
117
118
when ( licenseScaffolder . default )
118
119
. calledWith ( { projectRoot : projectPath , license, copyright} )
119
120
. mockResolvedValue ( licenseResults ) ;
120
- when ( vcsHostScaffolder . default )
121
+ when ( scaffoldVcsHost )
121
122
. calledWith (
122
123
vcsHosts ,
123
124
{
@@ -127,7 +128,7 @@ describe('project scaffolder', () => {
127
128
visibility
128
129
}
129
130
)
130
- . mockResolvedValue ( vcsOriginDetails ) ;
131
+ . mockResolvedValue ( vcsHostResults ) ;
131
132
scaffoldLanguage . mockResolvedValue ( languageResults ) ;
132
133
when ( dependencyUpdaterScaffolder . default )
133
134
. calledWith ( dependencyUpdaters , decisions , { projectRoot : projectPath , vcs} )
@@ -138,7 +139,7 @@ describe('project scaffolder', () => {
138
139
139
140
expect ( liftGit ) . toHaveBeenCalledWith ( {
140
141
projectRoot : projectPath ,
141
- origin : vcsOriginDetails
142
+ vcs : vcsOriginDetails
142
143
} ) ;
143
144
expect ( scaffoldReadme ) . toHaveBeenCalledWith ( { projectName, projectRoot : projectPath , description} ) ;
144
145
expect ( dependencyUpdaterScaffolder . default ) . toHaveBeenCalledWith (
@@ -173,7 +174,20 @@ describe('project scaffolder', () => {
173
174
[ coreQuestionNames . PROJECT_NAME ] : projectName ,
174
175
[ questionNames . GIT_REPO ] : gitRepoShouldBeInitialized
175
176
} ) ;
177
+
178
+ when ( scaffoldGit ) . mockResolvedValue ( vcs ) ;
176
179
languagePrompt . default . mockResolvedValue ( { } ) ;
180
+ when ( scaffoldVcsHost )
181
+ . calledWith (
182
+ { } ,
183
+ {
184
+ ...vcs ,
185
+ projectRoot : projectPath ,
186
+ description : undefined ,
187
+ visibility : undefined
188
+ }
189
+ )
190
+ . mockResolvedValue ( vcsHostResults ) ;
177
191
178
192
await scaffold ( ) ;
179
193
@@ -184,9 +198,10 @@ describe('project scaffolder', () => {
184
198
it ( 'should consider each option except the plugins map optional' , async ( ) => {
185
199
const emptyOptions = { } ;
186
200
when ( optionsValidator . validate ) . calledWith ( emptyOptions ) . mockReturnValue ( { plugins : { } } ) ;
187
- when ( prompts . promptForBaseDetails ) . calledWith ( projectPath , undefined , undefined ) . mockResolvedValue ( { } ) ;
201
+ when ( prompts . promptForBaseDetails ) . calledWith ( projectPath , undefined ) . mockResolvedValue ( { } ) ;
188
202
languagePrompt . default . mockResolvedValue ( { } ) ;
189
203
scaffoldGit . mockResolvedValue ( { } ) ;
204
+ scaffoldVcsHost . mockResolvedValue ( vcsHostResults ) ;
190
205
191
206
await scaffold ( emptyOptions ) ;
192
207
} ) ;
@@ -213,18 +228,36 @@ describe('project scaffolder', () => {
213
228
contribution : any . simpleObject ( )
214
229
} ;
215
230
const languageResults = { badges : languageBadges , vcsIgnore, documentation} ;
231
+ when ( optionsValidator . validate ) . calledWith ( options ) . mockReturnValue ( { plugins : { vcsHosts} } ) ;
216
232
when ( prompts . promptForBaseDetails )
217
- . calledWith ( projectPath , undefined , undefined )
218
- . mockResolvedValue ( { [ coreQuestionNames . VISIBILITY ] : visibility } ) ;
233
+ . calledWith ( projectPath , undefined )
234
+ . mockResolvedValue ( {
235
+ [ coreQuestionNames . DESCRIPTION ] : description ,
236
+ [ questionNames . GIT_REPO ] : true ,
237
+ [ coreQuestionNames . PROJECT_NAME ] : projectName ,
238
+ [ coreQuestionNames . VISIBILITY ] : visibility
239
+ } ) ;
219
240
when ( scaffoldContributing ) . calledWith ( { visibility} ) . mockReturnValue ( { badges : contributingBadges } ) ;
220
241
scaffoldLanguage . mockResolvedValue ( languageResults ) ;
221
- vcsHostScaffolder . default . mockResolvedValue ( vcsOriginDetails ) ;
242
+ when ( scaffoldVcsHost )
243
+ . calledWith (
244
+ vcsHosts ,
245
+ {
246
+ ...vcs ,
247
+ projectRoot : projectPath ,
248
+ description,
249
+ visibility
250
+ }
251
+ )
252
+ . mockResolvedValue ( vcsHostResults ) ;
222
253
dependencyUpdaterScaffolder . default . mockResolvedValue ( { badges : dependencyUpdaterBadges } ) ;
223
254
licenseScaffolder . default . mockResolvedValue ( { badges : licenseBadges } ) ;
255
+ languagePrompt . default . mockResolvedValue ( { } ) ;
256
+ when ( scaffoldGit ) . mockResolvedValue ( vcs ) ;
224
257
225
258
await scaffold ( options ) ;
226
259
227
- expect ( liftGit ) . toHaveBeenCalledWith ( { projectRoot : projectPath , origin : vcsOriginDetails } ) ;
260
+ expect ( liftGit ) . toHaveBeenCalledWith ( { projectRoot : projectPath , vcs : vcsOriginDetails } ) ;
228
261
expect ( scaffoldReadme ) . toHaveBeenCalledWith ( { projectName, projectRoot : projectPath , description} ) ;
229
262
} ) ;
230
263
@@ -238,7 +271,7 @@ describe('project scaffolder', () => {
238
271
await scaffold ( options ) ;
239
272
240
273
expect ( liftGit ) . not . toHaveBeenCalled ( ) ;
241
- expect ( vcsHostScaffolder . default ) . not . toHaveBeenCalled ( ) ;
274
+ expect ( scaffoldVcsHost ) . not . toHaveBeenCalled ( ) ;
242
275
expect ( dependencyUpdaterScaffolder . default ) . not . toHaveBeenCalled ( ) ;
243
276
} ) ;
244
277
@@ -287,26 +320,23 @@ describe('project scaffolder', () => {
287
320
vcs,
288
321
description
289
322
} ) . mockResolvedValue ( languageResults ) ;
290
- when ( vcsHostScaffolder . default ) . calledWith (
323
+ when ( scaffoldVcsHost ) . calledWith (
291
324
vcsHosts ,
292
325
{
293
326
...vcs ,
294
327
projectRoot : projectPath ,
295
328
description,
296
- homepage,
297
- visibility,
298
- nextSteps : languageNextSteps ,
299
- tags
329
+ visibility
300
330
}
301
- ) . mockResolvedValue ( vcsOriginDetails ) ;
331
+ ) . mockResolvedValue ( vcsHostResults ) ;
302
332
when ( execa ) . calledWith ( verificationCommand , { shell : true } ) . mockReturnValue ( { stdout : { pipe : execaPipe } } ) ;
303
333
dependencyUpdaterScaffolder . default . mockResolvedValue ( { } ) ;
304
334
licenseScaffolder . default . mockResolvedValue ( { } ) ;
305
335
scaffoldContributing . mockResolvedValue ( { } ) ;
306
336
307
337
await scaffold ( options ) ;
308
338
309
- expect ( liftGit ) . toHaveBeenCalledWith ( { projectRoot : projectPath , origin : vcsOriginDetails } ) ;
339
+ expect ( liftGit ) . toHaveBeenCalledWith ( { projectRoot : projectPath , vcs : vcsOriginDetails } ) ;
310
340
expect ( scaffoldReadme ) . toHaveBeenCalledWith ( { projectName, projectRoot : projectPath , description} ) ;
311
341
expect ( execaPipe ) . toHaveBeenCalledWith ( process . stdout ) ;
312
342
expect ( resultsReporter . reportResults ) . toHaveBeenCalledWith ( { nextSteps : [ ...languageNextSteps , ...gitNextSteps ] } ) ;
@@ -327,15 +357,15 @@ describe('project scaffolder', () => {
327
357
when ( languagePrompt . default )
328
358
. calledWith ( languages , decisions )
329
359
. mockResolvedValue ( { [ questionNames . PROJECT_LANGUAGE ] : projectLanguage } ) ;
330
- vcsHostScaffolder . default . mockResolvedValue ( vcsOriginDetails ) ;
360
+ scaffoldVcsHost . mockResolvedValue ( vcsHostResults ) ;
331
361
scaffoldLanguage . mockResolvedValue ( { } ) ;
332
362
dependencyUpdaterScaffolder . default . mockResolvedValue ( { } ) ;
333
363
licenseScaffolder . default . mockResolvedValue ( { } ) ;
334
364
scaffoldContributing . mockResolvedValue ( { } ) ;
335
365
336
366
await scaffold ( options ) ;
337
367
338
- expect ( liftGit ) . toHaveBeenCalledWith ( { projectRoot : projectPath , origin : vcsOriginDetails } ) ;
368
+ expect ( liftGit ) . toHaveBeenCalledWith ( { projectRoot : projectPath , vcs : vcsOriginDetails } ) ;
339
369
expect ( scaffoldReadme ) . toHaveBeenCalledWith ( { projectName, projectRoot : projectPath , description} ) ;
340
370
expect ( execa ) . not . toHaveBeenCalled ( ) ;
341
371
} ) ;
0 commit comments