-
Notifications
You must be signed in to change notification settings - Fork 38
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
- Loading branch information
1 parent
e3689bc
commit d1d1e8c
Showing
52 changed files
with
3,397 additions
and
65 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
49 changes: 49 additions & 0 deletions
49
...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,49 @@ | ||
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. | ||
* e.g. : [{ library: '@o3r/demo', properties: [{name : 'property1', type: 'string'}, {name : 'property2', type: 'number'}] }] | ||
* will become : | ||
* [{ library: '@o3r/demo', properties: [{name : 'property1', type: 'string'}] }, { library: '@o3r/demo', properties: [{name : 'property2', type: 'number'}] }] | ||
* | ||
* @param content Content of a migration metadata files | ||
*/ | ||
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.