Skip to content
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: add checkAfterItems in builders #2503

Open
wants to merge 1 commit into
base: release/11.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
"type": "string",
"description": "Path of the config metadata file.",
"default": "./component.config.metadata.json"
},
"checkAfterItems": {
"type": "boolean",
"description": "Whether after items should be checked.",
"default": true
}
},
"additionalProperties": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,7 @@ export interface MigrationMetadataCheckBuilderOptions extends JsonObject {

/** Entry to check for previous metadata in the `package.json` file under `cmsMetadata`. */
packageJsonEntry: keyof Omit<CmsMetadataData, 'libraryName'>;

/** Whether to check the items set in "after" property in the migration file. */
checkAfterItems: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function checkMetadataFile<MetadataItem, MigrationMetadataItem, MetadataFile>(
newMetadataFile: MetadataFile,
migrationData: MigrationData<MigrationMetadataItem>[],
isBreakingChangeAllowed: boolean,
checkAfterItems: boolean,
comparator: MetadataComparator<MetadataItem, MigrationMetadataItem, MetadataFile>
): Error[] {
const errors: Error[] = [];
Expand All @@ -40,7 +41,7 @@ function checkMetadataFile<MetadataItem, MigrationMetadataItem, MetadataFile>(
continue;
}

if (migrationMetadataValue.after) {
if (checkAfterItems && migrationMetadataValue.after) {
const isNewValueInNewMetadata = newMetadataArray.some((newValue) => comparator.isMigrationDataMatch(newValue, migrationMetadataValue.after!, migrationMetadataValue.contentType));
if (!isNewValueInNewMetadata) {
errors.push(new Error(`Property ${comparator.getIdentifier(lastValue)} has been modified but the new property is not present in the new metadata`));
Expand Down Expand Up @@ -161,7 +162,7 @@ Detection of package manager runner will fallback on the one used to execute the
const newFile = getLocalMetadataFile<MetadataFile>(metadataPathInWorkspace);


const errors = checkMetadataFile<MetadataItem, MigrationMetadataItem, MetadataFile>(metadata, newFile, migrationData.changes, options.allowBreakingChanges, comparator);
const errors = checkMetadataFile<MetadataItem, MigrationMetadataItem, MetadataFile>(metadata, newFile, migrationData.changes, options.allowBreakingChanges, options.checkAfterItems, comparator);

if (errors.length) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
"type": "string",
"description": "Path of the localization metadata file.",
"default": "./localisation.metadata.json"
},
"checkAfterItems": {
"type": "boolean",
"description": "Whether after items should be checked.",
"default": true
}
},
"additionalProperties": false,
Expand Down
5 changes: 5 additions & 0 deletions packages/@o3r/styling/builders/metadata-check/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
"type": "string",
"description": "Path of the styling metadata file.",
"default": "./style.metadata.json"
},
"checkAfterItems": {
"type": "boolean",
"description": "Whether after items should be checked.",
"default": true
}
},
"additionalProperties": false,
Expand Down
Loading