From 4c69a18c783383eb5239d3418774a11b1c5ea508 Mon Sep 17 00:00:00 2001 From: Bernie White Date: Thu, 5 May 2022 20:14:28 +1000 Subject: [PATCH] Added nodeps manifest #1392 (#1394) --- docs/CHANGELOG-v1.md | 1 + pipeline.build.ps1 | 25 ++++ .../PSRule.Rules.Azure-nodeps.psd1 | 136 ++++++++++++++++++ 3 files changed, 162 insertions(+) create mode 100644 src/PSRule.Rules.Azure/PSRule.Rules.Azure-nodeps.psd1 diff --git a/docs/CHANGELOG-v1.md b/docs/CHANGELOG-v1.md index e3b3812cc6..c87834d65b 100644 --- a/docs/CHANGELOG-v1.md +++ b/docs/CHANGELOG-v1.md @@ -31,6 +31,7 @@ What's changed since pre-release v1.15.0-B0022: - Engineering: - Embedded provider and alias information as manifest resources. [#1383](https://github.com/Azure/PSRule.Rules.Azure/issues/1383) - Resources are minified and compressed to improve size and speed. + - Added additional `nodeps` manifest that does not include dependencies for Az modules. [#1392](https://github.com/Azure/PSRule.Rules.Azure/issues/1392) - Bump Az.Accounts to 2.7.6. [#1338](https://github.com/Azure/PSRule.Rules.Azure/pull/1338) - Bump Az.Resources to 5.6.0. [#1338](https://github.com/Azure/PSRule.Rules.Azure/pull/1338) - Bump PSRule to 2.1.0. [#1338](https://github.com/Azure/PSRule.Rules.Azure/pull/1338) diff --git a/pipeline.build.ps1 b/pipeline.build.ps1 index 4af4b2aeb1..c70398df90 100644 --- a/pipeline.build.ps1 +++ b/pipeline.build.ps1 @@ -133,6 +133,31 @@ task VersionModule ModuleDependencies, { } }; Update-ModuleManifest -Path $manifestPath -RequiredModules $requiredModules; + + # Update -nodeps manifest + $manifestPath = Join-Path -Path $modulePath -ChildPath PSRule.Rules.Azure-nodeps.psd1; + if (![String]::IsNullOrEmpty($Build)) { + # Update module version + if (![String]::IsNullOrEmpty($version)) { + Write-Verbose -Message "[VersionModule] -- Updating module manifest ModuleVersion"; + Update-ModuleManifest -Path $manifestPath -ModuleVersion $version; + } + + # Update pre-release version + if (![String]::IsNullOrEmpty($versionSuffix)) { + Write-Verbose -Message "[VersionModule] -- Updating module manifest Prerelease"; + Update-ModuleManifest -Path $manifestPath -Prerelease $versionSuffix; + } + } + + $dependencies = Get-Content -Path $PWD/modules.json -Raw | ConvertFrom-Json; + $manifest = Test-ModuleManifest -Path $manifestPath; + $requiredModules = $manifest.RequiredModules | ForEach-Object -Process { + if ($_.Name -eq 'PSRule' -and $Configuration -eq 'Release') { + @{ ModuleName = 'PSRule'; ModuleVersion = $dependencies.dependencies.PSRule.version } + } + }; + Update-ModuleManifest -Path $manifestPath -RequiredModules $requiredModules; } # Synopsis: Publish to PowerShell Gallery diff --git a/src/PSRule.Rules.Azure/PSRule.Rules.Azure-nodeps.psd1 b/src/PSRule.Rules.Azure/PSRule.Rules.Azure-nodeps.psd1 new file mode 100644 index 0000000000..9cc08e9b1f --- /dev/null +++ b/src/PSRule.Rules.Azure/PSRule.Rules.Azure-nodeps.psd1 @@ -0,0 +1,136 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +# DO NOT USE + +# NOTE: +# This is a manifest that does not include dependencies to Az modules. +# Az modules are required for certain functions within PSRule for Azure. +# This manifest is a temporary workaround for a specific internal case. +# A more complete solution will be provided in the future. +# https://github.com/Azure/PSRule.Rules.Azure/issues/1392 +@{ + + # Script module or binary module file associated with this manifest. + RootModule = 'PSRule.Rules.Azure.psm1' + + # Version number of this module. + ModuleVersion = '0.0.1' + + # Supported PSEditions + CompatiblePSEditions = 'Core', 'Desktop' + + # ID used to uniquely identify this module + GUID = 'bce66f73-3809-4740-b3c3-f52958e7ab51' + + # Author of this module + Author = 'Microsoft Corporation' + + # Company or vendor of this module + CompanyName = 'Microsoft Corporation' + + # Copyright statement for this module + Copyright = '(c) Microsoft Corporation. All rights reserved.' + + # Description of the functionality provided by this module + Description = 'Validate Azure resources and infrastructure as code using PSRule. + +This project uses GitHub Issues to track bugs and feature requests. See GitHub project for more information.' + + # Minimum version of the Windows PowerShell engine required by this module + PowerShellVersion = '5.1' + + # Name of the Windows PowerShell host required by this module + # PowerShellHostName = '' + + # Minimum version of the Windows PowerShell host required by this module + # PowerShellHostVersion = '' + + # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. + DotNetFrameworkVersion = '4.7.2' + + # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. + # CLRVersion = '' + + # Processor architecture (None, X86, Amd64) required by this module + # ProcessorArchitecture = '' + + # Modules that must be imported into the global environment prior to importing this module + RequiredModules = @( + @{ ModuleName = 'PSRule'; ModuleVersion = '0.0.1' } + ) + + # Assemblies that must be loaded prior to importing this module + RequiredAssemblies = @( + 'PSRule.Rules.Azure.dll' + ) + + # Script files (.ps1) that are run in the caller's environment prior to importing this module. + # ScriptsToProcess = @() + + # Type files (.ps1xml) to be loaded when importing this module + # TypesToProcess = @() + + # Format files (.ps1xml) to be loaded when importing this module + # FormatsToProcess = @() + + # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess + # NestedModules = @() + + # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. + FunctionsToExport = @( + 'Export-AzRuleData' + 'Export-AzRuleTemplateData' + 'Get-AzRuleTemplateLink' + 'Export-AzPolicyAssignmentData' + 'Export-AzPolicyAssignmentRuleData' + 'Get-AzPolicyAssignmentDataSource' + ) + + # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. + CmdletsToExport = @() + + # Variables to export from this module + VariablesToExport = @() + + # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. + AliasesToExport = @( + 'Export-AzTemplateRuleData' + ) + + # DSC resources to export from this module + # DscResourcesToExport = @() + + # List of all modules packaged with this module + # ModuleList = @() + + # List of all files packaged with this module + # FileList = @() + + # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. + PrivateData = @{ + PSData = @{ + # Tags applied to this module. These help with module discovery in online galleries. + Tags = @('PSRule', 'PSRule-rules', 'Rule', 'Azure', 'Cloud', 'DevOps', 'Testing', 'Infrastructure') + + # A URL to the license for this module. + LicenseUri = 'https://github.com/Azure/PSRule.Rules.Azure/blob/main/LICENSE' + + # A URL to the main website for this project. + ProjectUri = 'https://aka.ms/ps-rule-azure' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + ReleaseNotes = 'https://github.com/Azure/PSRule.Rules.Azure/blob/main/CHANGELOG.md' + } # End of PSData hashtable + } # End of PrivateData hashtable + + # HelpInfo URI of this module + # HelpInfoURI = '' + + # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. + # DefaultCommandPrefix = '' + +}