-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from form8ion/alpha
- Loading branch information
Showing
15 changed files
with
223 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
|
||
|
||
|
||
|
||
/node_modules/ | ||
/lib/ | ||
/coverage/ | ||
|
||
.eslintcache | ||
.eslintcache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {default as scaffold} from './scaffolder.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {promises as fs} from 'node:fs'; | ||
import {XMLBuilder} from 'fast-xml-parser'; | ||
|
||
export default async function ({projectRoot, projectName}) { | ||
const builder = new XMLBuilder({format: true}); | ||
|
||
await fs.writeFile( | ||
`${projectRoot}/pom.xml`, | ||
builder.build({project: {modelVersion: '4.0.0', artifactId: projectName}}) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {promises as fs} from 'node:fs'; | ||
|
||
import {describe, expect, it, vi, afterEach} from 'vitest'; | ||
import any from '@travi/any'; | ||
|
||
import scaffold from './scaffolder.js'; | ||
|
||
vi.mock('node:fs'); | ||
|
||
describe('pom scaffolder', () => { | ||
afterEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
it('should create the pom file', async () => { | ||
const projectRoot = any.string(); | ||
const projectName = any.word(); | ||
|
||
await scaffold({projectRoot, projectName}); | ||
|
||
expect(fs.writeFile) | ||
.toHaveBeenCalledWith( | ||
`${projectRoot}/pom.xml`, | ||
`<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>${projectName}</artifactId> | ||
</project> | ||
` | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
export default function () { | ||
return undefined; | ||
import {scaffold as scaffoldPom} from './pom/index.js'; | ||
|
||
export default async function ({projectRoot, projectName}) { | ||
await scaffoldPom({projectRoot, projectName}); | ||
|
||
return {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {describe, it, expect, afterEach, vi} from 'vitest'; | ||
import any from '@travi/any'; | ||
|
||
import {scaffold as scaffoldPom} from './pom/index.js'; | ||
import scaffold from './scaffolder.js'; | ||
|
||
vi.mock('./pom/index.js'); | ||
|
||
describe('scaffolder', () => { | ||
afterEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
it('should configure java', async () => { | ||
const projectRoot = any.string(); | ||
const projectName = any.word(); | ||
|
||
expect(await scaffold({projectRoot, projectName})).toEqual({}); | ||
expect(scaffoldPom).toHaveBeenCalledWith({projectRoot, projectName}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
Feature: Scaffolder | ||
|
||
Scenario: Scaffold | ||
Given the project should be named "project-name" | ||
When the project is scaffolded | ||
Then the pom file is created |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {promises as fs} from 'node:fs'; | ||
import {XMLParser} from 'fast-xml-parser'; | ||
|
||
import {Then} from '@cucumber/cucumber'; | ||
import {assert} from 'chai'; | ||
|
||
Then('the pom file is created', async function () { | ||
const parser = new XMLParser(); | ||
const parsedContent = parser.parse(await fs.readFile(`${this.projectRoot}/pom.xml`, 'utf-8')); | ||
|
||
assert.deepEqual(parsedContent, {project: {modelVersion: '4.0.0', artifactId: this.projectName}}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {Given} from '@cucumber/cucumber'; | ||
|
||
Given('the project should be named {string}', async function (projectName) { | ||
this.projectName = projectName; | ||
}); |