-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(migrations): split #13499
Merged
rarkins
merged 24 commits into
renovatebot:main
from
pret-a-porter:feat/split_migrations
Jan 13, 2022
Merged
feat(migrations): split #13499
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
f4d3d19
refactor(migrations): implemented migration validator
pret-a-porter d974833
refactor(migrations): semantic commits
pret-a-porter 7a283fd
refactor(migrations): enabled managers
pret-a-porter 087a2b9
refactor(migrations): pin versions
pret-a-porter 1215dd3
refactor(migrations): introduce deprecated flag
pret-a-porter aa12a1c
refactor(migrations): rebase stale prs
pret-a-porter a43f277
refactor(migrations): tidy
pret-a-porter 1c9c0b7
refactor(migrations): improve validator
pret-a-porter 3232d37
refactor(migrations): rebase conflicted prs
pret-a-porter 909c98c
refactor(migrations): fix coverage
pret-a-porter b0d345c
Merge branch 'main' into refactor/migration_validator
pret-a-porter 64b5a67
refactor(migrations): fix coverage
pret-a-porter 64e61f5
refactor(migrations): fix build
pret-a-porter c69be7f
Merge branch 'main' into refactor/migration_validator
pret-a-porter beaad84
refactor: fix launch.json
pret-a-porter 79a6cfc
Merge branch 'renovatebot:main' into refactor/migrations_temp
pret-a-porter 1499b70
Merge branch 'main' into refactor/migrations_temp
pret-a-porter 066112f
refactor: adjust migrations
pret-a-porter 728ee61
feat: add override modifier
pret-a-porter d739b74
Apply suggestions from code review
rarkins 5ba375f
Merge branch 'main' into feat/split_migrations
pret-a-porter 706faf5
feat: fix unit test
pret-a-porter 67bb0ca
Merge branch 'main' into feat/split_migrations
JamieMagee 8024c4d
Merge branch 'main' into feat/split_migrations
rarkins File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
14 changes: 14 additions & 0 deletions
14
lib/config/migrations/custom/enabled-managers-migration.spec.ts
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,14 @@ | ||
import { EnabledManagersMigration } from './enabled-managers-migration'; | ||
|
||
describe('config/migrations/custom/enabled-managers-migration', () => { | ||
it('should replace yarn with npm', () => { | ||
expect(EnabledManagersMigration).toMigrate( | ||
{ | ||
enabledManagers: ['test1', 'yarn', 'test2'], | ||
}, | ||
{ | ||
enabledManagers: ['test1', 'npm', 'test2'], | ||
} | ||
); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
lib/config/migrations/custom/enabled-managers-migration.ts
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,15 @@ | ||
import is from '@sindresorhus/is'; | ||
import { AbstractMigration } from '../base/abstract-migration'; | ||
|
||
export class EnabledManagersMigration extends AbstractMigration { | ||
readonly propertyName = 'enabledManagers'; | ||
|
||
override run(value: string[]): void { | ||
if (is.array(value)) { | ||
const newValue = value.map((manager) => | ||
manager === 'yarn' ? 'npm' : manager | ||
); | ||
this.rewrite(newValue); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
lib/config/migrations/custom/pin-versions-migration.spec.ts
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,25 @@ | ||
import { PinVersionsMigration } from './pin-versions-migration'; | ||
|
||
describe('config/migrations/custom/pin-versions-migration', () => { | ||
it('should migrate true', () => { | ||
expect(PinVersionsMigration).toMigrate( | ||
{ | ||
pinVersions: true, | ||
}, | ||
{ | ||
rangeStrategy: 'pin', | ||
} | ||
); | ||
}); | ||
|
||
it('should migrate false', () => { | ||
expect(PinVersionsMigration).toMigrate( | ||
{ | ||
pinVersions: false, | ||
}, | ||
{ | ||
rangeStrategy: 'replace', | ||
} | ||
); | ||
}); | ||
}); |
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 is from '@sindresorhus/is'; | ||
import { AbstractMigration } from '../base/abstract-migration'; | ||
|
||
export class PinVersionsMigration extends AbstractMigration { | ||
override readonly deprecated = true; | ||
readonly propertyName = 'pinVersions'; | ||
|
||
override run(value): void { | ||
if (is.boolean(value)) { | ||
this.setSafely('rangeStrategy', value ? 'pin' : 'replace'); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
lib/config/migrations/custom/rebase-conflicted-prs-migration.spec.ts
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,14 @@ | ||
import { RebaseConflictedPrs } from './rebase-conflicted-prs-migration'; | ||
|
||
describe('config/migrations/custom/rebase-conflicted-prs-migration', () => { | ||
it('should migrate false', () => { | ||
expect(RebaseConflictedPrs).toMigrate( | ||
{ | ||
rebaseConflictedPrs: false, | ||
}, | ||
{ | ||
rebaseWhen: 'never', | ||
} | ||
); | ||
}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
lib/config/migrations/custom/rebase-conflicted-prs-migration.ts
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 { AbstractMigration } from '../base/abstract-migration'; | ||
|
||
export class RebaseConflictedPrs extends AbstractMigration { | ||
override readonly deprecated = true; | ||
readonly propertyName = 'rebaseConflictedPrs'; | ||
|
||
override run(value): void { | ||
if (value === false) { | ||
this.setSafely('rebaseWhen', 'never'); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
lib/config/migrations/custom/rebase-stale-prs-migration.spec.ts
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,36 @@ | ||
import { RebaseStalePrsMigration } from './rebase-stale-prs-migration'; | ||
|
||
describe('config/migrations/custom/rebase-stale-prs-migration', () => { | ||
it('should migrate true', () => { | ||
expect(RebaseStalePrsMigration).toMigrate( | ||
{ | ||
rebaseStalePrs: true, | ||
}, | ||
{ | ||
rebaseWhen: 'behind-base-branch', | ||
} | ||
); | ||
}); | ||
|
||
it('should migrate false', () => { | ||
expect(RebaseStalePrsMigration).toMigrate( | ||
{ | ||
rebaseStalePrs: false, | ||
}, | ||
{ | ||
rebaseWhen: 'conflicted', | ||
} | ||
); | ||
}); | ||
|
||
it('should migrate null', () => { | ||
expect(RebaseStalePrsMigration).toMigrate( | ||
{ | ||
rebaseStalePrs: null, | ||
}, | ||
{ | ||
rebaseWhen: 'auto', | ||
} | ||
); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
lib/config/migrations/custom/rebase-stale-prs-migration.ts
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,24 @@ | ||
import is from '@sindresorhus/is'; | ||
import { AbstractMigration } from '../base/abstract-migration'; | ||
|
||
export class RebaseStalePrsMigration extends AbstractMigration { | ||
override readonly deprecated = true; | ||
readonly propertyName = 'rebaseStalePrs'; | ||
|
||
override run(value): void { | ||
const rebaseConflictedPrs = this.get('rebaseConflictedPrs'); | ||
|
||
if (rebaseConflictedPrs !== false) { | ||
if (is.boolean(value)) { | ||
this.setSafely( | ||
'rebaseWhen', | ||
value ? 'behind-base-branch' : 'conflicted' | ||
); | ||
} | ||
|
||
if (is.null_(value)) { | ||
this.setSafely('rebaseWhen', 'auto'); | ||
} | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
lib/config/migrations/custom/semantic-commits-migration.spec.ts
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,59 @@ | ||
import { SemanticCommitsMigration } from './semantic-commits-migration'; | ||
|
||
describe('config/migrations/custom/semantic-commits-migration', () => { | ||
it('should migrate true to "enabled"', () => { | ||
expect(SemanticCommitsMigration).toMigrate( | ||
{ | ||
semanticCommits: true, | ||
} as any, | ||
JamieMagee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ semanticCommits: 'enabled' } | ||
); | ||
}); | ||
|
||
it('should migrate false to "disabled"', () => { | ||
expect(SemanticCommitsMigration).toMigrate( | ||
{ | ||
semanticCommits: false, | ||
} as any, | ||
{ semanticCommits: 'disabled' } | ||
); | ||
}); | ||
|
||
it('should migrate null to "auto"', () => { | ||
expect(SemanticCommitsMigration).toMigrate( | ||
{ | ||
semanticCommits: null, | ||
} as any, | ||
{ semanticCommits: 'auto' } | ||
); | ||
}); | ||
|
||
it('should migrate random string to "auto"', () => { | ||
expect(SemanticCommitsMigration).toMigrate( | ||
{ | ||
semanticCommits: 'test', | ||
} as any, | ||
{ semanticCommits: 'auto' } | ||
); | ||
}); | ||
|
||
it('should not migrate valid enabled config', () => { | ||
expect(SemanticCommitsMigration).toMigrate( | ||
{ | ||
semanticCommits: 'enabled', | ||
} as any, | ||
{ semanticCommits: 'enabled' }, | ||
false | ||
); | ||
}); | ||
|
||
it('should not migrate valid disabled config', () => { | ||
expect(SemanticCommitsMigration).toMigrate( | ||
{ | ||
semanticCommits: 'disabled', | ||
} as any, | ||
{ semanticCommits: 'disabled' }, | ||
false | ||
); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
lib/config/migrations/custom/semantic-commits-migration.ts
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,14 @@ | ||
import is from '@sindresorhus/is'; | ||
import { AbstractMigration } from '../base/abstract-migration'; | ||
|
||
export class SemanticCommitsMigration extends AbstractMigration { | ||
readonly propertyName = 'semanticCommits'; | ||
|
||
override run(value): void { | ||
if (is.boolean(value)) { | ||
this.rewrite(value ? 'enabled' : 'disabled'); | ||
} else if (value !== 'enabled' && value !== 'disabled') { | ||
this.rewrite('auto'); | ||
} | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the double negative is a little confusing
or
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I re-read this, I realise that
rebaseConflictedPrs
isboolean | undefined
so you'd needrebaseConflictedPrs === true || rebaseConflictedPrs === undefined
. Gotta love that trinary logic 😅