From dd73a7122f7ae1b4e089d82cf42fb5f712c3381b Mon Sep 17 00:00:00 2001 From: Trae Yelovich Date: Tue, 23 Jan 2024 10:22:26 -0500 Subject: [PATCH] feat: replace schema if newer one has changed Signed-off-by: Trae Yelovich --- .../imperative/src/config/src/ProfileInfo.ts | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/imperative/src/config/src/ProfileInfo.ts b/packages/imperative/src/config/src/ProfileInfo.ts index 95c67a24f2..c9959a4e02 100644 --- a/packages/imperative/src/config/src/ProfileInfo.ts +++ b/packages/imperative/src/config/src/ProfileInfo.ts @@ -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 { + 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` + }; + } + + // 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] = { + version: typeInfo.schema.version, + from: typeMetadata.from.filter((src) => src !== typeInfo.sourceApp).concat([typeInfo.sourceApp]) + }; + this.updateSchemaAtLayer(profileType, typeInfo.schema, true); + } } } else { // Newly-contributed profile type; track in extenders.json