Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(migrations): extend abstract migration (#12963)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
- Loading branch information
1 parent
c7dbbd8
commit a4249f9
Showing
17 changed files
with
163 additions
and
105 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
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,14 +1,11 @@ | ||
import type { RenovateConfig } from '../../types'; | ||
import { AbstractMigration } from '../base/abstract-migration'; | ||
|
||
export class BinarySourceMigration extends AbstractMigration { | ||
constructor(originalConfig: RenovateConfig, migratedConfig: RenovateConfig) { | ||
super('binarySource', originalConfig, migratedConfig); | ||
} | ||
readonly propertyName = 'binarySource'; | ||
|
||
override run(): void { | ||
if (this.originalConfig.binarySource === 'auto') { | ||
this.migratedConfig.binarySource = 'global'; | ||
override run(value): void { | ||
if (value === 'auto') { | ||
this.rewrite('global'); | ||
} | ||
} | ||
} |
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,19 +1,18 @@ | ||
import type { RenovateConfig } from '../../types'; | ||
import { AbstractMigration } from '../base/abstract-migration'; | ||
|
||
export class GoModTidyMigration extends AbstractMigration { | ||
constructor(originalConfig: RenovateConfig, migratedConfig: RenovateConfig) { | ||
super('gomodTidy', originalConfig, migratedConfig); | ||
} | ||
readonly propertyName = 'gomodTidy'; | ||
|
||
override run(): void { | ||
const { gomodTidy, postUpdateOptions } = this.originalConfig; | ||
override run(value): void { | ||
const postUpdateOptions = this.get('postUpdateOptions'); | ||
|
||
this.delete(this.propertyName); | ||
|
||
if (gomodTidy) { | ||
this.migratedConfig.postUpdateOptions ??= postUpdateOptions ?? []; | ||
this.migratedConfig.postUpdateOptions.push('gomodTidy'); | ||
if (value) { | ||
const newPostUpdateOptions = Array.isArray(postUpdateOptions) | ||
? postUpdateOptions.concat(['gomodTidy']) | ||
: ['gomodTidy']; | ||
this.setHard('postUpdateOptions', newPostUpdateOptions); | ||
} | ||
} | ||
} |
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
11 changes: 3 additions & 8 deletions
11
lib/config/migrations/custom/ignore-node-modules-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 |
---|---|---|
@@ -1,16 +1,11 @@ | ||
import type { RenovateConfig } from '../../types'; | ||
import { AbstractMigration } from '../base/abstract-migration'; | ||
|
||
export class IgnoreNodeModulesMigration extends AbstractMigration { | ||
constructor(originalConfig: RenovateConfig, migratedConfig: RenovateConfig) { | ||
super('ignoreNodeModules', originalConfig, migratedConfig); | ||
} | ||
readonly propertyName = 'ignoreNodeModules'; | ||
|
||
override run(): void { | ||
override run(value): void { | ||
this.delete(this.propertyName); | ||
|
||
this.migratedConfig.ignorePaths = this.originalConfig.ignoreNodeModules | ||
? ['node_modules/'] | ||
: []; | ||
this.setSafely('ignorePaths', value ? ['node_modules/'] : []); | ||
} | ||
} |
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
11 changes: 4 additions & 7 deletions
11
lib/config/migrations/custom/required-status-checks-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 |
---|---|---|
@@ -1,16 +1,13 @@ | ||
import type { RenovateConfig } from '../../types'; | ||
import { AbstractMigration } from '../base/abstract-migration'; | ||
|
||
export class RequiredStatusChecksMigration extends AbstractMigration { | ||
constructor(originalConfig: RenovateConfig, migratedConfig: RenovateConfig) { | ||
super('requiredStatusChecks', originalConfig, migratedConfig); | ||
} | ||
readonly propertyName = 'requiredStatusChecks'; | ||
|
||
override run(): void { | ||
override run(value): void { | ||
this.delete(this.propertyName); | ||
|
||
if (this.originalConfig.requiredStatusChecks === null) { | ||
this.migratedConfig.ignoreTests = true; | ||
if (value === null) { | ||
this.setSafely('ignoreTests', true); | ||
} | ||
} | ||
} |
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,21 +1,15 @@ | ||
import type { RenovateConfig } from '../../types'; | ||
import { AbstractMigration } from '../base/abstract-migration'; | ||
|
||
export class TrustLevelMigration extends AbstractMigration { | ||
constructor(originalConfig: RenovateConfig, migratedConfig: RenovateConfig) { | ||
super('trustLevel', originalConfig, migratedConfig); | ||
} | ||
readonly propertyName = 'trustLevel'; | ||
|
||
override run(): void { | ||
override run(value): void { | ||
this.delete(this.propertyName); | ||
|
||
if (this.originalConfig.trustLevel === 'high') { | ||
this.migratedConfig.allowCustomCrateRegistries = | ||
this.originalConfig.allowCustomCrateRegistries ?? true; | ||
this.migratedConfig.allowScripts = | ||
this.originalConfig.allowScripts ?? true; | ||
this.migratedConfig.exposeAllEnv = | ||
this.originalConfig.exposeAllEnv ?? true; | ||
if (value === 'high') { | ||
this.setSafely('allowCustomCrateRegistries', true); | ||
this.setSafely('allowScripts', true); | ||
this.setSafely('exposeAllEnv', true); | ||
} | ||
} | ||
} |
Oops, something went wrong.