Skip to content

feat: refactor IoT workflow migrations - #772

Open
jsousa02 wants to merge 1 commit into
criticalmanufacturing:developmentfrom
jsousa02:development-refactor-iot-workflow-migrations
Open

feat: refactor IoT workflow migrations#772
jsousa02 wants to merge 1 commit into
criticalmanufacturing:developmentfrom
jsousa02:development-refactor-iot-workflow-migrations

Conversation

@jsousa02

@jsousa02 jsousa02 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

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 upgrade command was being used as a placeholder so users could use the cmf upgrade base command. The latter is an anti-pattern since it goes through all the package files and performs an upgrade. Now, the cmf upgrade command is no longer a placeholder and can be used to perform an upgrade in the specified package only.
The cmf upgrade base behavior 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:

  • Code validation (careful with side-effects)
  • Integration test run provided
  • Main WorkItem is linked
  • Target branch version is correct

@jsousa02
jsousa02 force-pushed the development-refactor-iot-workflow-migrations branch from b9208a5 to 7428a77 Compare July 15, 2026 13:49
};
cmd.Add(manifestOption);

cmd.SetAction((parseResult) =>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we not using the cmd.Handler = CommandHandler.Create<IDirectoryInfo, string, bool>(this.Execute); ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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("*", "");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when would you have a * here?

@jsousa02 jsousa02 Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example customization project that I was using for testing had it, maybe that's not the case anymore
image

contentToPack.Source,
SearchOption.AllDirectories
));
workflowsFolder = fileSystem.Path.GetFullPath(fileSystem.Path.Combine(cmfPackage.GetFileInfo().DirectoryName, contentToPack.Source)).Replace("*", "");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I understand why you changed this versus the original code

@jsousa02 jsousa02 Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you removed the .json enforcement for upgrade, is this intentional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That logic was moved to the utility on the product's side

@jrk94 jrk94 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add tests using an update manifest

@jsousa02

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants