-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new builders for metadata migration check (#1732)
## Proposed change <!-- Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that is required for this change. --> Add 3 new builders in @o3r/component, @o3r/styling and @o3r/localization, check-config-migration-metadata, check-localization-styling -metadata and check-localization-migration-metadata The goal of these builders is to retrieve a previous version of the app (provided as an option or computed from the folder of migration metadata) and compare the current metadata with the previous one. It will raise some errors if breaking changes are detected and they are not allowed, or if these changes are not documented in the provided migration metadata. ## Related issues - 🐛 Fixes #(issue) - 🚀 Feature #(issue) <!-- Please make sure to follow the contributing guidelines on https://github.com/amadeus-digital/Otter/blob/main/CONTRIBUTING.md -->
- Loading branch information
Showing
51 changed files
with
3,483 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
registry=http://127.0.0.1:4873 | ||
registry=http://127.0.0.1:4873/ |
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
53 changes: 53 additions & 0 deletions
53
...ages/@o3r/components/builders/metadata-check/helpers/config-metadata-comparison.helper.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,53 @@ | ||
import type { ComponentConfigOutput } from '@o3r/components'; | ||
import type { MetadataComparator } from '@o3r/extractors'; | ||
|
||
/** | ||
* Interface describing a config migration element | ||
*/ | ||
export interface MigrationConfigData { | ||
/** Library name */ | ||
libraryName: string; | ||
/** | ||
* Configuration name | ||
*/ | ||
configName?: string; | ||
/** | ||
* Configuration property name | ||
*/ | ||
propertyName?: string; | ||
} | ||
|
||
/** | ||
* Returns an array of config metadata from a metadata file. | ||
* To be easily parseable, the properties will be split in separate items of the array. | ||
* @param content Content of a migration metadata files | ||
* @example Array conversion | ||
* ```javascript | ||
* [{ library: '@o3r/demo', properties: [{name : 'property1', type: 'string'}, {name : 'property2', type: 'number'}] }] | ||
* ``` | ||
* will become : | ||
* ```javascript | ||
* [{ library: '@o3r/demo', properties: [{name : 'property1', type: 'string'}] }, { library: '@o3r/demo', properties: [{name : 'property2', type: 'number'}] }] | ||
* ``` | ||
*/ | ||
const getConfigurationArray = (content: ComponentConfigOutput[]): ComponentConfigOutput[] => content.flatMap((config) => | ||
config.properties.length > 1 | ||
? config.properties.map((prop) => ({...config, properties: [prop]})) | ||
: [config] | ||
); | ||
|
||
const getConfigurationPropertyName = (config: ComponentConfigOutput) => `${config.library}#${config.name}` + (config.properties.length ? ` ${config.properties[0].name}` : ''); | ||
|
||
const isMigrationConfigurationDataMatch = (config: ComponentConfigOutput, migrationData: MigrationConfigData) => | ||
migrationData.libraryName === config.library | ||
&& (!migrationData.configName || migrationData.configName === config.name) | ||
&& (!migrationData.propertyName || config.properties[0]?.name === migrationData.propertyName); | ||
|
||
/** | ||
* Comparator used to compare one version of config metadata with another | ||
*/ | ||
export const configMetadataComparator: MetadataComparator<ComponentConfigOutput, MigrationConfigData, ComponentConfigOutput[]> = { | ||
getArray: getConfigurationArray, | ||
getIdentifier: getConfigurationPropertyName, | ||
isMigrationDataMatch: isMigrationConfigurationDataMatch | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/@o3r/components/builders/metadata-check/helpers/index.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 @@ | ||
export * from './config-metadata-comparison.helper'; |
Oops, something went wrong.