-
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.
feat(vcs): defined the tag property under scm when lifting
for #9
- Loading branch information
Showing
7 changed files
with
77 additions
and
2 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 +1,2 @@ | ||
export {default as scaffold} from './scaffolder.js'; | ||
export {lift} from './pom/index.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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export {default as scaffold} from './scaffolder.js'; | ||
export {default as lift} from './lifter.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,13 @@ | ||
import {promises as fs} from 'node:fs'; | ||
import {XMLBuilder, XMLParser} from 'fast-xml-parser'; | ||
|
||
export default async function ({projectRoot}) { | ||
const pathToPom = `${projectRoot}/pom.xml`; | ||
const parser = new XMLParser(); | ||
const builder = new XMLBuilder({format: true}); | ||
const existingPomContents = parser.parse(await fs.readFile(pathToPom, 'utf-8')); | ||
existingPomContents.project.scm = {tag: 'HEAD'}; | ||
await fs.writeFile(pathToPom, builder.build(existingPomContents)); | ||
|
||
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,34 @@ | ||
import {promises as fs} from 'node:fs'; | ||
|
||
import {describe, it, expect, vi, afterEach} from 'vitest'; | ||
import any from '@travi/any'; | ||
import {when} from 'jest-when'; | ||
|
||
import liftPom from './lifter.js'; | ||
|
||
vi.mock('node:fs'); | ||
|
||
describe('pom lifter', () => { | ||
afterEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
it('should define the vcs details', async () => { | ||
const projectRoot = any.string(); | ||
when(fs.readFile) | ||
.calledWith(`${projectRoot}/pom.xml`, 'utf-8') | ||
.mockResolvedValue('<project><modelVersion>4.0.0</modelVersion></project>'); | ||
|
||
expect(await liftPom({projectRoot})).toEqual({}); | ||
expect(fs.writeFile).toHaveBeenCalledWith( | ||
`${projectRoot}/pom.xml`, | ||
`<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<scm> | ||
<tag>HEAD</tag> | ||
</scm> | ||
</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
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,16 @@ | ||
import {promises as fs} from 'node:fs'; | ||
|
||
import {Given, Then} from '@cucumber/cucumber'; | ||
import {XMLParser} from 'fast-xml-parser'; | ||
import {assert} from 'chai'; | ||
|
||
Given('vcs details are not defined in the pom', async function () { | ||
await fs.writeFile(`${this.projectRoot}/pom.xml`, '<project><modelVersion>4.0.0</modelVersion></project>'); | ||
}); | ||
|
||
Then('vcs details are defined in the pom', async function () { | ||
const parser = new XMLParser(); | ||
const {project: {scm}} = parser.parse(await fs.readFile(`${this.projectRoot}/pom.xml`, 'utf-8')); | ||
|
||
assert.deepEqual(scm, {tag: 'HEAD'}); | ||
}); |
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,6 @@ | ||
Feature: Version Control Details | ||
|
||
Scenario: No Details Defined | ||
Given vcs details are not defined in the pom | ||
When the project is lifted | ||
Then vcs details are defined in the pom |