Skip to content

Commit 9322e3a

Browse files
committed
feat(vcs-hosts): moved vcs-host scaffolding to earlier since lifting can be a separate phase now
1 parent 969e585 commit 9322e3a

File tree

2 files changed

+39
-40
lines changed

2 files changed

+39
-40
lines changed

src/scaffolder.js

+25-31
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,24 @@ export async function scaffold(options) {
4040
scaffoldEditorConfig({projectRoot})
4141
]);
4242

43+
const [vcsHostResults, dependencyUpdaterResults] = vcs
44+
? await Promise.all([
45+
scaffoldVcsHost(vcsHosts, {
46+
...vcs,
47+
projectRoot,
48+
description,
49+
visibility
50+
}),
51+
scaffoldDependencyUpdater(
52+
dependencyUpdaters,
53+
decisions,
54+
{projectRoot, vcs}
55+
)
56+
])
57+
: [];
58+
59+
const gitResults = gitRepo && await liftGit({projectRoot, origin: vcsHostResults});
60+
4361
const {[questionNames.PROJECT_LANGUAGE]: projectLanguage} = await promptForLanguageDetails(languages, decisions);
4462

4563
const language = await scaffoldLanguage(
@@ -48,34 +66,10 @@ export async function scaffold(options) {
4866
{projectRoot, projectName, vcs, visibility, license: chosenLicense || 'UNLICENSED', description}
4967
);
5068

51-
const dependencyUpdaterResults = vcs && await scaffoldDependencyUpdater(
52-
dependencyUpdaters,
53-
decisions,
54-
{projectRoot, vcs}
55-
);
56-
57-
const contributors = [license, language, dependencyUpdaterResults, contributing].filter(Boolean);
58-
const contributedTasks = contributors
59-
.map(contributor => contributor.nextSteps)
60-
.filter(Boolean)
61-
.reduce((acc, contributedNextSteps) => ([...acc, ...contributedNextSteps]), []);
62-
63-
const vcsHostResults = vcs && await scaffoldVcsHost(vcsHosts, {
64-
...vcs,
65-
projectRoot,
66-
description,
67-
visibility,
68-
...language && {
69-
homepage: language.projectDetails && language.projectDetails.homepage,
70-
tags: language.tags
71-
},
72-
nextSteps: contributedTasks
73-
});
69+
const contributors = [license, language, dependencyUpdaterResults, contributing, gitResults].filter(Boolean);
7470

7571
await lift({projectRoot, vcs, results: deepmerge.all(contributors), enhancers: {...dependencyUpdaters, ...vcsHosts}});
7672

77-
const gitResults = gitRepo && await liftGit({projectRoot, origin: vcsHostResults});
78-
7973
if (language && language.verificationCommand) {
8074
info('Verifying the generated project');
8175

@@ -84,10 +78,10 @@ export async function scaffold(options) {
8478
await subprocess;
8579
}
8680

87-
reportResults({
88-
nextSteps: [
89-
...(gitResults && gitResults.nextSteps) ? gitResults.nextSteps : [],
90-
...contributedTasks
91-
]
92-
});
81+
const contributedTasks = contributors
82+
.map(contributor => contributor.nextSteps)
83+
.filter(Boolean)
84+
.reduce((acc, contributedNextSteps) => ([...acc, ...contributedNextSteps]), []);
85+
86+
reportResults({nextSteps: contributedTasks});
9387
}

src/scaffolder.test.js

+14-9
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ describe('project scaffolder', () => {
9191
tags
9292
};
9393
const licenseResults = {badges: {consumer: {license: licenseBadge}}};
94+
const gitResults = {nextSteps: gitNextSteps};
9495
const contributingResults = any.simpleObject();
9596
when(optionsValidator.validate)
9697
.calledWith(options)
@@ -112,7 +113,7 @@ describe('project scaffolder', () => {
112113
when(scaffoldGit)
113114
.calledWith(gitRepoShouldBeInitialized, projectPath, projectName, vcsHosts, visibility, decisions)
114115
.mockResolvedValue(vcs);
115-
liftGit.mockResolvedValue({nextSteps: gitNextSteps});
116+
liftGit.mockResolvedValue(gitResults);
116117
when(licenseScaffolder.default)
117118
.calledWith({projectRoot: projectPath, license, copyright})
118119
.mockResolvedValue(licenseResults);
@@ -123,10 +124,7 @@ describe('project scaffolder', () => {
123124
...vcs,
124125
projectRoot: projectPath,
125126
description,
126-
visibility,
127-
homepage: undefined,
128-
nextSteps: [...dependencyUpdaterNextSteps],
129-
tags
127+
visibility
130128
}
131129
)
132130
.mockResolvedValue(vcsOriginDetails);
@@ -152,11 +150,17 @@ describe('project scaffolder', () => {
152150
expect(lift).toHaveBeenCalledWith({
153151
projectRoot: projectPath,
154152
vcs,
155-
results: deepmerge.all([licenseResults, languageResults, dependencyUpdaterResults, contributingResults]),
153+
results: deepmerge.all([
154+
licenseResults,
155+
languageResults,
156+
dependencyUpdaterResults,
157+
contributingResults,
158+
gitResults
159+
]),
156160
enhancers: {...dependencyUpdaters, ...vcsHosts}
157161
});
158162
expect(resultsReporter.reportResults).toHaveBeenCalledWith({
159-
nextSteps: [...gitNextSteps, ...dependencyUpdaterNextSteps]
163+
nextSteps: [...dependencyUpdaterNextSteps, ...gitNextSteps]
160164
});
161165
});
162166

@@ -259,11 +263,12 @@ describe('project scaffolder', () => {
259263
nextSteps: languageNextSteps,
260264
tags
261265
};
266+
const gitResults = {nextSteps: gitNextSteps};
262267
when(optionsValidator.validate)
263268
.calledWith(options)
264269
.mockReturnValue({decisions, plugins: {languages, vcsHosts}});
265270
scaffoldGit.mockResolvedValue(vcs);
266-
liftGit.mockResolvedValue({nextSteps: gitNextSteps});
271+
liftGit.mockResolvedValue(gitResults);
267272
prompts.promptForBaseDetails.mockResolvedValue({
268273
[coreQuestionNames.PROJECT_NAME]: projectName,
269274
[coreQuestionNames.VISIBILITY]: visibility,
@@ -304,7 +309,7 @@ describe('project scaffolder', () => {
304309
expect(liftGit).toHaveBeenCalledWith({projectRoot: projectPath, origin: vcsOriginDetails});
305310
expect(scaffoldReadme).toHaveBeenCalledWith({projectName, projectRoot: projectPath, description});
306311
expect(execaPipe).toHaveBeenCalledWith(process.stdout);
307-
expect(resultsReporter.reportResults).toHaveBeenCalledWith({nextSteps: [...gitNextSteps, ...languageNextSteps]});
312+
expect(resultsReporter.reportResults).toHaveBeenCalledWith({nextSteps: [...languageNextSteps, ...gitNextSteps]});
308313
});
309314

310315
it('should consider the language details to be optional', async () => {

0 commit comments

Comments
 (0)