Skip to content

Commit

Permalink
feat: add packageJsonEntry and checkAfterItems in builders
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumerochelle committed Nov 22, 2024
1 parent 2c094a7 commit dd84a6b
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
10 changes: 10 additions & 0 deletions packages/@o3r/components/builders/metadata-check/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@
"type": "string",
"description": "Path of the config metadata file.",
"default": "./component.config.metadata.json"
},
"packageJsonEntry": {
"type": "string",
"description": "Entry to check for previous metadata in the `package.json` file under `cmsMetadata`.",
"default": "configurationFilePath"
},
"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
10 changes: 10 additions & 0 deletions packages/@o3r/localization/builders/metadata-check/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@
"type": "string",
"description": "Path of the localization metadata file.",
"default": "./localisation.metadata.json"
},
"packageJsonEntry": {
"type": "string",
"description": "Entry to check for previous metadata in the `package.json` file under `cmsMetadata`.",
"default": "localizationFilePath"
},
"checkAfterItems": {
"type": "boolean",
"description": "Whether after items should be checked.",
"default": true
}
},
"additionalProperties": false,
Expand Down
10 changes: 10 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,16 @@
"type": "string",
"description": "Path of the styling metadata file.",
"default": "./style.metadata.json"
},
"packageJsonEntry": {
"type": "string",
"description": "Entry to check for previous metadata in the `package.json` file under `cmsMetadata`.",
"default": "styleFilePath"
},
"checkAfterItems": {
"type": "boolean",
"description": "Whether after items should be checked.",
"default": true
}
},
"additionalProperties": false,
Expand Down

0 comments on commit dd84a6b

Please sign in to comment.