feat: refactor IoT workflow migrations - #772
Conversation
b9208a5 to
7428a77
Compare
| }; | ||
| cmd.Add(manifestOption); | ||
|
|
||
| cmd.SetAction((parseResult) => |
There was a problem hiding this comment.
Why are we not using the cmd.Handler = CommandHandler.Create<IDirectoryInfo, string, bool>(this.Execute); ?
There was a problem hiding this comment.
The commands were updated to use this new format. Check this commit
| contentToPack.Source, | ||
| SearchOption.AllDirectories | ||
| )); | ||
| workflowsFolder = fileSystem.Path.GetFullPath(fileSystem.Path.Combine(cmfPackage.GetFileInfo().DirectoryName, contentToPack.Source)).Replace("*", ""); |
There was a problem hiding this comment.
when would you have a * here?
| contentToPack.Source, | ||
| SearchOption.AllDirectories | ||
| )); | ||
| workflowsFolder = fileSystem.Path.GetFullPath(fileSystem.Path.Combine(cmfPackage.GetFileInfo().DirectoryName, contentToPack.Source)).Replace("*", ""); |
There was a problem hiding this comment.
I am not sure I understand why you changed this versus the original code
There was a problem hiding this comment.
Because the workflow migration utility receives a folder and does the searching for the files. It's better to pass a folder instead of all the files as arguments to the utility considering that it can be used standalone.
| JObject packageJsonObject = JsonConvert.DeserializeObject<JObject>(text); | ||
|
|
||
| if (packageJsonObject.ContainsKey("<DM>AutomationController")) | ||
| if (!string.IsNullOrEmpty(workflowsFolder)) |
There was a problem hiding this comment.
you removed the .json enforcement for upgrade, is this intentional?
There was a problem hiding this comment.
That logic was moved to the utility on the product's side
jrk94
left a comment
There was a problem hiding this comment.
please add tests using an update manifest
Tests for this already exist on the Product's side. I think it makes more sense to have them there, since the logic is also there. |

What was done
The previous IoT workflow upgrade process consisted of changing the tasks' version in the JSON file, which is against the recommendations of the Product team. A new utility, the workflow-migration-tool, was developed as a standalone npm package. The utility goes through all the masterdata and workflow files and updates the tasks, applying all the migration scripts needed. This is the correct, safe way to perform these kinds of upgrades.
The
cmf upgradecommand was being used as a placeholder so users could use thecmf upgrade basecommand. The latter is an anti-pattern since it goes through all the package files and performs an upgrade. Now, thecmf upgradecommand is no longer a placeholder and can be used to perform an upgrade in the specified package only.The
cmf upgrade basebehavior was kept.Finally, existing unit tests were updated and new ones were added for the UpgradeCommand.
Closes #758 #759 #760
Dependencies
Depends on the Connect IoT workflow-migration-tool package.
Validation checklist
Please ensure the following conditions are met in order for this PR to be merged: