Skip to content

Commit

Permalink
feat(lift-results): enable language results to be passed to vcs-host …
Browse files Browse the repository at this point in the history
…lifters
  • Loading branch information
travi committed Jan 25, 2025
1 parent 7c13cf1 commit 028affc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/scaffolder.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export async function scaffold(options) {
projectRoot,
vcs: vcsResults.vcs,
results: mergedResults,
enhancers: {...dependencyUpdaters, ...vcsHosts, ...languages}
enhancers: {...dependencyUpdaters, ...languages, ...vcsHosts}
});

if (language && language.verificationCommand) {
Expand Down
2 changes: 2 additions & 0 deletions test/integration/features/scaffold/git.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ Feature: Git Repository
Scenario: to be versioned and hosted
Given the project should be versioned in git
And the git repository will be hosted
And a language scaffolder is chosen
When the project is scaffolded
Then the remote origin is defined
And the project repository is hosted on the chosen host

Scenario: already versioned
Given the project root is already initialized as a git repository
Expand Down
23 changes: 19 additions & 4 deletions test/integration/features/step_definitions/common-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ When(/^the project is scaffolded$/, async function () {

this.projectName = 'project-name';
this.projectDescription = any.sentence();
this.projectHomepage = any.url();

this.languageLiftResults = any.simpleObject();
this.languageLiftResults = {...any.simpleObject(), homepage: this.projectHomepage};

await scaffold({
plugins: {
Expand Down Expand Up @@ -85,9 +86,23 @@ When(/^the project is scaffolded$/, async function () {
...vcsHost && 'Other' !== vcsHost && {
vcsHosts: {
[vcsHost]: {
scaffold: ({projectName, owner}) => ({
vcs: {sshUrl: this.remoteOriginUrl, name: projectName, owner, host: vcsHost}
})
scaffold: ({projectName, owner}) => {
this.hostedVcsDetails = {name: projectName, host: vcsHost};

return ({
vcs: {sshUrl: this.remoteOriginUrl, name: projectName, owner, host: vcsHost}
});
},
test: ({projectRoot}) => {
info(`Determining if project at ${projectRoot} uses the ${vcsHost} VCS host`);

return true;
},
lift: ({results}) => {
this.vcsHostProjectHomepage = results.homepage;

return results;
}
}
}
}
Expand Down
13 changes: 11 additions & 2 deletions test/integration/features/step_definitions/vcs/vcs-host-steps.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import {Given} from '@cucumber/cucumber';
import {Given, Then} from '@cucumber/cucumber';
import any from '@travi/any';
import {assert} from 'chai';

import {questionNames} from '../../../../../src/prompts/question-names.js';

Given('the git repository will be hosted', async function () {
this.setAnswerFor(questionNames.REPO_HOST, any.word());
const vcsHost = any.word();

this.setAnswerFor(questionNames.REPO_HOST, vcsHost);
this.remoteOriginUrl = any.url();
this.repoHost = vcsHost;
});

Given('the repository is hosted on {string}', async function (host) {
this.repoHost = host;
this.vcsOwner = any.word();
this.vcsName = any.word();
});

Then('the project repository is hosted on the chosen host', async function () {
assert.deepEqual(this.hostedVcsDetails, {name: this.projectName, host: this.repoHost});
assert.equal(this.vcsHostProjectHomepage, this.projectHomepage);
});

0 comments on commit 028affc

Please sign in to comment.