Skip to content

Commit

Permalink
feat: replace schema if newer one has changed
Browse files Browse the repository at this point in the history
Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com>
  • Loading branch information
traeok committed Jan 23, 2024
1 parent 34c0840 commit dd73a71
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions packages/imperative/src/config/src/ProfileInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1403,12 +1403,24 @@ export class ProfileInfo {
};
this.updateSchemaAtLayer(profileType, typeInfo.schema, true);
}
} else if (typeInfo.schema.version != null) {
// Warn user if this schema does not provide a valid version number
return {
success: false,
info: `New schema type for profile type ${profileType} is not SemVer-compliant; schema was not updated`
};
} else {

Check warning on line 1406 in packages/imperative/src/config/src/ProfileInfo.ts

View check run for this annotation

Codecov / codecov/patch

packages/imperative/src/config/src/ProfileInfo.ts#L1406

Added line #L1406 was not covered by tests
if (typeInfo.schema.version != null) {
// Warn user if this schema does not provide a valid version number
return {

Check warning on line 1409 in packages/imperative/src/config/src/ProfileInfo.ts

View check run for this annotation

Codecov / codecov/patch

packages/imperative/src/config/src/ProfileInfo.ts#L1409

Added line #L1409 was not covered by tests
success: false,
info: `New schema type for profile type ${profileType} is not SemVer-compliant; schema was not updated`
};
}

// If the old schema doesn't have a tracked version and its different from the one passed into this function, use the new schema
if (this.mExtendersJson.profileTypes[profileType].version == null &&
!lodash.isEqual({ ...typeInfo.schema, version: undefined }, { ...this.getSchemaForType(profileType), version: undefined })) {
this.mExtendersJson.profileTypes[profileType] = {

Check warning on line 1418 in packages/imperative/src/config/src/ProfileInfo.ts

View check run for this annotation

Codecov / codecov/patch

packages/imperative/src/config/src/ProfileInfo.ts#L1417-L1418

Added lines #L1417 - L1418 were not covered by tests
version: typeInfo.schema.version,
from: typeMetadata.from.filter((src) => src !== typeInfo.sourceApp).concat([typeInfo.sourceApp])

Check warning on line 1420 in packages/imperative/src/config/src/ProfileInfo.ts

View check run for this annotation

Codecov / codecov/patch

packages/imperative/src/config/src/ProfileInfo.ts#L1420

Added line #L1420 was not covered by tests
};
this.updateSchemaAtLayer(profileType, typeInfo.schema, true);

Check warning on line 1422 in packages/imperative/src/config/src/ProfileInfo.ts

View check run for this annotation

Codecov / codecov/patch

packages/imperative/src/config/src/ProfileInfo.ts#L1422

Added line #L1422 was not covered by tests
}
}
} else {
// Newly-contributed profile type; track in extenders.json
Expand Down

0 comments on commit dd73a71

Please sign in to comment.