11# Helper functions for retireving useful information from azure-sdk-for-* repo
2- # Example Use : Import-Module .\eng\common\scripts\modules
32class PackageProps
43{
5- [string ]$pkgName
6- [string ]$pkgVersion
7- [string ]$pkgDirectoryPath
8- [string ]$pkgServiceName
9- [string ]$pkgReadMePath
10- [string ]$pkgChangeLogPath
11- [string ]$pkgGroup
12-
13- PackageProps([string ]$pkgName , [string ]$pkgVersion , [string ]$pkgDirectoryPath , [string ]$pkgServiceName )
4+ [string ]$Name
5+ [string ]$Version
6+ [string ]$DirectoryPath
7+ [string ]$ServiceDirectory
8+ [string ]$ReadMePath
9+ [string ]$ChangeLogPath
10+ [string ]$Group
11+
12+ PackageProps([string ]$name , [string ]$version , [string ]$directoryPath , [string ]$serviceDirectory )
1413 {
15- $this.Initialize ($pkgName , $pkgVersion , $pkgDirectoryPath , $pkgServiceName )
14+ $this.Initialize ($name , $version , $directoryPath , $serviceDirectory )
1615 }
1716
18- PackageProps([string ]$pkgName , [string ]$pkgVersion , [string ]$pkgDirectoryPath , [string ]$pkgServiceName , [string ]$pkgGroup = " " )
17+ PackageProps([string ]$name , [string ]$version , [string ]$directoryPath , [string ]$serviceDirectory , [string ]$group = " " )
1918 {
20- $this.Initialize ($pkgName , $pkgVersion , $pkgDirectoryPath , $pkgServiceName , $pkgGroup )
19+ $this.Initialize ($name , $version , $directoryPath , $serviceDirectory , $group )
2120 }
2221
2322 hidden [void ]Initialize(
24- [string ]$pkgName ,
25- [string ]$pkgVersion ,
26- [string ]$pkgDirectoryPath ,
27- [string ]$pkgServiceName
23+ [string ]$name ,
24+ [string ]$version ,
25+ [string ]$directoryPath ,
26+ [string ]$serviceDirectory
2827 )
2928 {
30- $this.pkgName = $pkgName
31- $this.pkgVersion = $pkgVersion
32- $this.pkgDirectoryPath = $pkgDirectoryPath
33- $this.pkgServiceName = $pkgServiceName
29+ $this.Name = $name
30+ $this.Version = $version
31+ $this.DirectoryPath = $directoryPath
32+ $this.ServiceDirectory = $serviceDirectory
3433
35- if (Test-Path (Join-Path $pkgDirectoryPath " README.md" ))
34+ if (Test-Path (Join-Path $directoryPath " README.md" ))
3635 {
37- $this.pkgReadMePath = Join-Path $pkgDirectoryPath " README.md"
36+ $this.ReadMePath = Join-Path $directoryPath " README.md"
3837 }
3938 else
4039 {
41- $this.pkgReadMePath = $null
40+ $this.ReadMePath = $null
4241 }
4342
44- if (Test-Path (Join-Path $pkgDirectoryPath " CHANGELOG.md" ))
43+ if (Test-Path (Join-Path $directoryPath " CHANGELOG.md" ))
4544 {
46- $this.pkgChangeLogPath = Join-Path $pkgDirectoryPath " CHANGELOG.md"
45+ $this.ChangeLogPath = Join-Path $directoryPath " CHANGELOG.md"
4746 }
4847 else
4948 {
50- $this.pkgChangeLogPath = $null
49+ $this.ChangeLogPath = $null
5150 }
5251 }
5352
5453 hidden [void ]Initialize(
55- [string ]$pkgName ,
56- [string ]$pkgVersion ,
57- [string ]$pkgDirectoryPath ,
58- [string ]$pkgServiceName ,
59- [string ]$pkgGroup
54+ [string ]$name ,
55+ [string ]$version ,
56+ [string ]$directoryPath ,
57+ [string ]$serviceDirectory ,
58+ [string ]$group
6059 )
6160 {
62- $this.Initialize ($pkgName , $pkgVersion , $pkgDirectoryPath , $pkgServiceName )
63- $this.pkgGroup = $pkgGroup
61+ $this.Initialize ($name , $version , $directoryPath , $serviceDirectory )
62+ $this.Group = $group
6463 }
6564}
6665
@@ -72,18 +71,17 @@ function Get-PkgProperties
7271{
7372 Param
7473 (
75- [Parameter (Mandatory = $true )]
74+ [Parameter (Mandatory = $true )]
7675 [string ]$PackageName ,
77- [Parameter (Mandatory = $true )]
78- [string ]$ServiceName
76+ [Parameter (Mandatory = $true )]
77+ [string ]$ServiceDirectory
7978 )
8079
81- $pkgDirectoryName = $null
8280 $pkgDirectoryPath = $null
83- $serviceDirectoryPath = Join-Path $RepoRoot " sdk" $ServiceName
81+ $serviceDirectoryPath = Join-Path $RepoRoot " sdk" $ServiceDirectory
8482 if (! (Test-Path $serviceDirectoryPath ))
8583 {
86- Write-Error " Service Directory $ServiceName does not exist"
84+ Write-Error " Service Directory $ServiceDirectory does not exist"
8785 exit 1
8886 }
8987
@@ -92,13 +90,13 @@ function Get-PkgProperties
9290 foreach ($directory in $directoriesPresent )
9391 {
9492 $pkgDirectoryPath = Join-Path $serviceDirectoryPath $directory.Name
95- if ($ExtractPkgProps )
93+ if ($GetPackageInfoFromRepoFn )
9694 {
97- $pkgProps = & $ExtractPkgProps - pkgPath $pkgDirectoryPath - serviceName $ServiceName - pkgName $PackageName
95+ $pkgProps = & $GetPackageInfoFromRepoFn - pkgPath $pkgDirectoryPath - serviceDirectory $ServiceDirectory - pkgName $PackageName
9896 }
9997 else
10098 {
101- Write-Error " The function '${ExtractPkgProps} ' was not found."
99+ Write-Error " The function 'Get- ${Language} -PackageInfoFromRepo ' was not found."
102100 }
103101
104102 if ($pkgProps -ne $null )
@@ -112,11 +110,11 @@ function Get-PkgProperties
112110# Takes ServiceName and Repo Root Directory
113111# Returns important properties for each package in the specified service, or entire repo if the serviceName is not specified
114112# Returns an Table of service key to array values of PS Object with properties @ { pkgName, pkgVersion, pkgDirectoryPath, pkgReadMePath, pkgChangeLogPath }
115- function Get-AllPkgProperties ([string ]$ServiceName = $null )
113+ function Get-AllPkgProperties ([string ]$ServiceDirectory = $null )
116114{
117115 $pkgPropsResult = @ ()
118116
119- if ([string ]::IsNullOrEmpty($ServiceName ))
117+ if ([string ]::IsNullOrEmpty($ServiceDirectory ))
120118 {
121119 $searchDir = Join-Path $RepoRoot " sdk"
122120 foreach ($dir in (Get-ChildItem $searchDir - Directory))
@@ -128,32 +126,32 @@ function Get-AllPkgProperties ([string]$ServiceName=$null)
128126 $activePkgList = Get-PkgListFromYml - ciYmlPath (Join-Path $serviceDir " ci.yml" )
129127 if ($activePkgList -ne $null )
130128 {
131- $pkgPropsResult = Operate- OnPackages - activePkgList $activePkgList - serviceName $dir.Name - pkgPropsResult $pkgPropsResult
129+ $pkgPropsResult = Operate- OnPackages - activePkgList $activePkgList - ServiceDirectory $dir.Name - pkgPropsResult $pkgPropsResult
132130 }
133131 }
134132 }
135133 }
136134 else
137135 {
138- $serviceDir = Join-Path $RepoRoot " sdk" $ServiceName
136+ $serviceDir = Join-Path $RepoRoot " sdk" $ServiceDirectory
139137 if (Test-Path (Join-Path $serviceDir " ci.yml" ))
140138 {
141139 $activePkgList = Get-PkgListFromYml - ciYmlPath (Join-Path $serviceDir " ci.yml" )
142140 if ($activePkgList -ne $null )
143141 {
144- $pkgPropsResult = Operate- OnPackages - activePkgList $activePkgList - serviceName $ServiceName - pkgPropsResult $pkgPropsResult
142+ $pkgPropsResult = Operate- OnPackages - activePkgList $activePkgList - ServiceDirectory $ServiceDirectory - pkgPropsResult $pkgPropsResult
145143 }
146144 }
147145 }
148146
149147 return $pkgPropsResult
150148}
151149
152- function Operate-OnPackages ($activePkgList , $serviceName , [Array ]$pkgPropsResult )
150+ function Operate-OnPackages ($activePkgList , $ServiceDirectory , [Array ]$pkgPropsResult )
153151{
154152 foreach ($pkg in $activePkgList )
155153 {
156- $pkgProps = Get-PkgProperties - PackageName $pkg [" name" ] - ServiceName $serviceName
154+ $pkgProps = Get-PkgProperties - PackageName $pkg [" name" ] - ServiceDirectory $ServiceDirectory
157155 $pkgPropsResult += $pkgProps
158156 }
159157 return $pkgPropsResult
@@ -168,11 +166,11 @@ function Get-PkgListFromYml ($ciYmlPath)
168166 $ciYmlObj = ConvertFrom-Yaml $ciYmlContent - Ordered
169167 if ($ciYmlObj.Contains (" stages" ))
170168 {
171- $artifactsInCI = $ciYmlObj [" stages" ][0 ][" parameters" ][" Artifacts" ]
169+ $artifactsInCI = $ciYmlObj [" stages" ][0 ][" parameters" ][" Artifacts" ]
172170 }
173171 elseif ($ciYmlObj.Contains (" extends" ))
174172 {
175- $artifactsInCI = $ciYmlObj [" extends" ][" parameters" ][" Artifacts" ]
173+ $artifactsInCI = $ciYmlObj [" extends" ][" parameters" ][" Artifacts" ]
176174 }
177175 if ($artifactsInCI -eq $null )
178176 {
0 commit comments