Skip to content

Commit

Permalink
Merge pull request #1868 from form8ion/beta
Browse files Browse the repository at this point in the history
promote to stable
  • Loading branch information
travi authored Feb 10, 2025
2 parents 2b9cddc + 7f87342 commit b1701b7
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 22 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ jobs:
matrix:
node:
- 18.19.0
- 20.6.1
- 22.0.0
- 22
- 20.9.0
- 22.11.0
- 23
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand Down
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"version": "0.0.0-semantically-released",
"type": "module",
"engines": {
"node": "^18.19.0 || ^20.6.1 || >=22"
"node": "^18.19.0 || ^20.9.0 || >=22.11.0"
},
"author": "Matt Travi <[email protected]> (https://matt.travi.org/)",
"contributors": [
Expand Down Expand Up @@ -95,7 +95,6 @@
"jest-when": "3.7.0",
"lockfile-lint": "4.14.0",
"ls-engines": "0.9.3",
"make-dir": "4.0.0",
"mdast-util-from-markdown": "2.0.2",
"mdast-util-heading-range": "4.0.0",
"mdast-zone": "6.1.0",
Expand Down
3 changes: 1 addition & 2 deletions src/lift.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import deepmerge from 'deepmerge';
import {applyEnhancers} from '@form8ion/core';
import {lift as liftReadme} from '@form8ion/readme';
import * as gitPlugin from '@form8ion/git';
Expand All @@ -13,7 +12,7 @@ export default async function ({projectRoot, results, enhancers, vcs, dependenci
dependencies
});

await liftReadme({projectRoot, results: deepmerge.all([results, enhancerResults])});
await liftReadme({projectRoot, results: enhancerResults});

return enhancerResults;
}
5 changes: 1 addition & 4 deletions src/lift.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import deepmerge from 'deepmerge';
import * as core from '@form8ion/core';
import * as readme from '@form8ion/readme';
import * as gitPlugin from '@form8ion/git';
Expand Down Expand Up @@ -26,7 +25,6 @@ describe('lift', () => {
const vcs = any.simpleObject();
const results = any.simpleObject();
const enhancerResults = any.simpleObject();
const mergedResults = any.simpleObject();
when(core.applyEnhancers)
.calledWith({
results,
Expand All @@ -35,9 +33,8 @@ describe('lift', () => {
dependencies
})
.mockResolvedValue(enhancerResults);
when(deepmerge.all).calledWith([results, enhancerResults]).mockReturnValue(mergedResults);

expect(await lift({projectRoot, results, enhancers, vcs, dependencies})).toEqual(enhancerResults);
expect(readme.lift).toHaveBeenCalledWith({projectRoot, results: mergedResults});
expect(readme.lift).toHaveBeenCalledWith({projectRoot, results: enhancerResults});
});
});
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}
enhancers: {...dependencyUpdaters, ...languages, ...vcsHosts}
});

if (language && language.verificationCommand) {
Expand Down
2 changes: 1 addition & 1 deletion src/scaffolder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('project scaffolder', () => {
projectRoot: projectPath,
vcs,
results: mergedResults,
enhancers: {...dependencyUpdaters, ...vcsHosts}
enhancers: {...dependencyUpdaters, ...vcsHosts, ...languages}
});
expect(resultsReporter.reportResults).toHaveBeenCalledWith(mergedResults);
});
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
33 changes: 30 additions & 3 deletions test/integration/features/step_definitions/common-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +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(), homepage: this.projectHomepage};

await scaffold({
plugins: {
Expand All @@ -66,16 +69,40 @@ When(/^the project is scaffolded$/, async function () {
info(`Scaffolding ${chosenLanguage} language details for ${projectName}`);

return this.languageScaffolderResults;
},
test: ({projectRoot}) => {
info(`Determining if project at ${projectRoot} uses the ${chosenLanguage} language`);

return true;
},
lift: ({projectRoot}) => {
info(`Applying the ${chosenLanguage} language lifter to the project at ${projectRoot}`);

return this.languageLiftResults;
}
}
}
},
...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
3 changes: 1 addition & 2 deletions test/integration/features/step_definitions/vcs/git-steps.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {promises as fs} from 'node:fs';

import {GitError} from 'simple-git';
import makeDir from 'make-dir';
import {fileExists} from '@form8ion/core';

import {Before, Given, Then} from '@cucumber/cucumber';
Expand Down Expand Up @@ -34,7 +33,7 @@ Given('the project root is already initialized as a git repository', async funct
this.existingVcsIgnoredFiles = any.listOf(any.word);
this.existingVcsIgnoredDirectories = any.listOf(any.word);

await makeDir(`${process.cwd()}/.git`);
await fs.mkdir(`${process.cwd()}/.git`, {recursive: true});
await fs.writeFile(
`${process.cwd()}/.gitignore`,
`${this.existingVcsIgnoredDirectories.join('\n')}\n\n${this.existingVcsIgnoredFiles.join('\n')}`
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 b1701b7

Please sign in to comment.