-
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(config): migrate legacy config name to modern config name
- Loading branch information
Showing
9 changed files
with
75 additions
and
6 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
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 |
---|---|---|
@@ -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,8 @@ | ||
import {promises as fs} from 'node:fs'; | ||
import {fileExists} from '@form8ion/core'; | ||
|
||
export default async function ({projectRoot}) { | ||
if (await fileExists(`${projectRoot}/renovate.json`)) { | ||
await fs.rename(`${projectRoot}/renovate.json`, `${projectRoot}/.renovaterc.json`); | ||
} | ||
} |
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,35 @@ | ||
import {promises as fs} from 'node:fs'; | ||
import {fileExists} from '@form8ion/core'; | ||
|
||
import any from '@travi/any'; | ||
import {when} from 'jest-when'; | ||
import {afterEach, describe, expect, it, vi} from 'vitest'; | ||
|
||
import liftConfig from './lifter.js'; | ||
|
||
vi.mock('node:fs'); | ||
vi.mock('@form8ion/core'); | ||
|
||
describe('config lifter', () => { | ||
const projectRoot = any.string(); | ||
|
||
afterEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
it('should move legacy config to the modern filename', async () => { | ||
when(fileExists).calledWith(`${projectRoot}/renovate.json`).mockResolvedValue(true); | ||
|
||
await liftConfig({projectRoot}); | ||
|
||
expect(fs.rename).toHaveBeenCalledWith(`${projectRoot}/renovate.json`, `${projectRoot}/.renovaterc.json`); | ||
}); | ||
|
||
it('should not attempt to move legacy config if none exists', async () => { | ||
when(fileExists).calledWith(`${projectRoot}/renovate.json`).mockResolvedValue(false); | ||
|
||
await liftConfig({projectRoot}); | ||
|
||
expect(fs.rename).not.toHaveBeenCalled(); | ||
}); | ||
}); |
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
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: Lift Config | ||
|
||
Scenario: legacy config | ||
Given the project uses a renovate config with the legacy filename | ||
When the scaffolder results are processed | ||
Then the project uses config with the modern filename |
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,8 +1,19 @@ | ||
import {promises as fs} from 'node:fs'; | ||
import {fileExists} from '@form8ion/core'; | ||
|
||
import {Given} from '@cucumber/cucumber'; | ||
import assert from 'node:assert'; | ||
import {Given, Then} from '@cucumber/cucumber'; | ||
import any from '@travi/any'; | ||
|
||
Given('the project uses a renovate config with the modern filename', async function () { | ||
await fs.writeFile(`${this.projectRoot}/.renovaterc.json`, JSON.stringify(any.simpleObject())); | ||
}); | ||
|
||
Given('the project uses a renovate config with the legacy filename', async function () { | ||
await fs.writeFile(`${this.projectRoot}/renovate.json`, JSON.stringify(any.simpleObject())); | ||
}); | ||
|
||
Then('the project uses config with the modern filename', async function () { | ||
assert.equal(await fileExists(`${this.projectRoot}/renovate.json`), false); | ||
assert.equal(await fileExists(`${this.projectRoot}/.renovaterc.json`), true); | ||
}); |