mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-08-31 10:58:28 +00:00
fix(config): correctly detect v1 vs v2 config and preserve versions node
- Determine config version by presence of "system" and "template" nodes instead of "versions", since a v2 config can also include "versions" and was previously being skipped from merging as a result. - Preserve the "versions" node after merging a v1 config, since PortalConfigReader.MergeConfigs does not carry it forward.
This commit is contained in:
parent
2f7789b374
commit
47e186d8f4
1 changed files with 17 additions and 6 deletions
|
|
@ -135,12 +135,14 @@ namespace PepperDash.Essentials.Core.Config
|
||||||
{
|
{
|
||||||
var parsedConfig = JObject.Parse(fs.ReadToEnd());
|
var parsedConfig = JObject.Parse(fs.ReadToEnd());
|
||||||
|
|
||||||
// Check if it's a v2 config (check for "version" node)
|
// A config is v1 if it has separate "system" and "template" nodes that
|
||||||
// this means it's already merged by the Portal API
|
// need to be merged. A v2 config is already merged by the Portal API and
|
||||||
// from the v2 config tool
|
// will not have "system"/"template" nodes. This is independent of whether
|
||||||
var isV2Config = parsedConfig["versions"] != null;
|
// a "versions" node is present, which only carries version metadata and
|
||||||
|
// can appear on either a v1 or v2 config.
|
||||||
if (isV2Config)
|
var isV1Config = parsedConfig["system"] != null && parsedConfig["template"] != null;
|
||||||
|
|
||||||
|
if (!isV1Config)
|
||||||
{
|
{
|
||||||
Debug.LogMessage(LogEventLevel.Information, "Config file is a v2 format, no merge necessary.");
|
Debug.LogMessage(LogEventLevel.Information, "Config file is a v2 format, no merge necessary.");
|
||||||
ConfigObject = parsedConfig.ToObject<EssentialsConfig>();
|
ConfigObject = parsedConfig.ToObject<EssentialsConfig>();
|
||||||
|
|
@ -148,6 +150,8 @@ namespace PepperDash.Essentials.Core.Config
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Config file is a v1 format, merging system and template.");
|
||||||
|
|
||||||
// Extract SystemUrl and TemplateUrl into final config output
|
// Extract SystemUrl and TemplateUrl into final config output
|
||||||
ConfigObject = PortalConfigReader.MergeConfigs(parsedConfig).ToObject<EssentialsConfig>();
|
ConfigObject = PortalConfigReader.MergeConfigs(parsedConfig).ToObject<EssentialsConfig>();
|
||||||
|
|
||||||
|
|
@ -160,6 +164,13 @@ namespace PepperDash.Essentials.Core.Config
|
||||||
{
|
{
|
||||||
ConfigObject.TemplateUrl = parsedConfig["template_url"].Value<string>();
|
ConfigObject.TemplateUrl = parsedConfig["template_url"].Value<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MergeConfigs does not carry the "versions" node forward, so it must be
|
||||||
|
// applied separately to ensure it's preserved in the merged config.
|
||||||
|
if (parsedConfig["versions"] != null)
|
||||||
|
{
|
||||||
|
ConfigObject.Versions = parsedConfig["versions"].ToObject<VersionData>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.LogMessage(LogEventLevel.Information, "Successfully Loaded Merged Config");
|
Debug.LogMessage(LogEventLevel.Information, "Successfully Loaded Merged Config");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue