Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the dependencies for Az.Accounts #15154

Merged
merged 1 commit into from
Jun 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion tools/VersionController/Models/VersionBumper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public void BumpAllVersions()
UpdateChangeLog();
var releaseNotes = GetReleaseNotes();
UpdateOutputModuleManifest(releaseNotes);
UpdateDependentModules();
UpdateRollupModuleManifest();
UpdateAssemblyInfo();
Console.WriteLine("Finished bumping version " + moduleName + "\n");
Expand Down Expand Up @@ -354,7 +355,7 @@ private void UpdateOutputModuleManifest(List<string> releaseNotes)
var outputModuleManifestPath = _fileHelper.OutputModuleManifestPath;
var projectModuleManifestPath = _fileHelper.ProjectModuleManifestPath;
var tempModuleManifestPath = Path.Combine(outputModuleDirectory, moduleName + "-temp.psd1");
File.Copy(outputModuleManifestPath, tempModuleManifestPath);
File.Copy(outputModuleManifestPath, tempModuleManifestPath, true);
var script = "$releaseNotes = @();";
releaseNotes.ForEach(l => script += "$releaseNotes += \"" + l + "\";");
script += $"$env:PSModulePath+=\";{_fileHelper.OutputResourceManagerDirectory}\";";
Expand All @@ -378,6 +379,34 @@ private void UpdateOutputModuleManifest(List<string> releaseNotes)
File.Delete(tempModuleManifestPath);
}

/// <summary>
/// Update the ModuleVersion of the bumped module in any dependent module's RequiredModule field.
/// </summary>
private void UpdateDependentModules()
{
var moduleName = _fileHelper.ModuleName;
var projectDirectories = _fileHelper.ProjectDirectories;
foreach (var projectDirectory in projectDirectories)
{
var moduleManifestPaths = Directory.GetFiles(projectDirectory, "*.psd1", SearchOption.AllDirectories)
.Where(f => !f.Contains("Netcore") &&
!f.Contains("bin") &&
!f.Contains("dll-Help") &&
!ModuleFilter.IsAzureStackModule(f))
.ToList();
foreach (var moduleManifestPath in moduleManifestPaths)
{
var file = File.ReadAllLines(moduleManifestPath);
var pattern = @"ModuleName(\s*)=(\s*)(['\""])" + moduleName + @"(['\""])(\s*);(\s*)ModuleVersion(\s*)=(\s*)(['\""])" + "\\d+(\\.\\d+)+" + @"(['\""])";
if (file.Where(l => Regex.IsMatch(l, pattern)).Any())
{
var updatedFile = file.Select(l => Regex.Replace(l, pattern, "ModuleName = '" + moduleName + "'; ModuleVersion = '" + _newVersion + "'"));
File.WriteAllLines(moduleManifestPath, updatedFile);
}
}
}
}

/// <summary>
/// Creates a new header for the upcoming release based on the new version.
/// </summary>
Expand Down