1+ function Invoke-SwaggerCI {
2+ param (
3+ [string ] $ConfigFilePath = " ./generateInput.json" ,
4+ [string ] $ResultFilePath = " ./generateOutput.json"
5+ )
6+
7+ # Get the readme.md files need to be run from config file
8+ $config = Get-Content $ConfigFilePath | ConvertFrom-Json
9+
10+ $packages = @ ()
11+ $downloadPrefix = $config.installInstructionInput.downloadUrlPrefix
12+ foreach ($rd in $config.relatedReadmeMdFiles ) {
13+ try {
14+ $rdFolder = Join-Path $config.specFolder (Split-Path $rd - Parent)
15+ $rdPath = Join-Path $rdFolder " readme.md"
16+ $psRdPath = Join-Path $rdFolder " readme.powershell.md"
17+ $modulePath = $rd.split (" /" )[1 ]
18+
19+ # create the a folder for this RP
20+ $moduleFolder = Join-Path (Join-Path (pwd).Path swaggerci) $modulePath
21+ New-Item - Path $moduleFolder - ItemType Directory - Force
22+
23+ # populate read.md.template
24+ $rdContent = Get-Content ./ tools/ SwaggerCI/ readme.md.template
25+ $rdContent = $rdContent.replace (' $(readme.md)' , $rdPath )
26+ $rdContent = $rdContent.replace (' $(readme.powershell.md)' , $psRdPath )
27+ $rdContent | Out-File - Path (Join-Path $moduleFolder " readme.md" )
28+
29+ # generate code
30+ autorest (Join-Path $moduleFolder " readme.md" ) -- version:3.0 .6371
31+ # Build the module
32+ . (Join-Path $moduleFolder " build-module.ps1" )
33+ # Override the generated .gitignore file
34+ cp ./ tools/ SwaggerCI/ gitignoreconf (Join-Path $moduleFolder " .gitignore" )
35+ # Package
36+ . (Join-Path $moduleFolder " pack-module.ps1" )
37+
38+ $moduleName = (Get-ChildItem - Path $moduleFolder - Recurse - Filter " *.nupkg" ).Name.Split(' .' )[1 ]
39+
40+ # Generate result
41+ $downloadUrl = $config.installInstructionInput.downloadUrlPrefix + " Az.$moduleName /Az.$moduleName .0.1.0.nupkg"
42+ $downloadCmd = " curl -L $downloadUrl -o Az.$moduleName .0.1.0.nupkg"
43+ $package = @ {
44+ packageName = " Az.$moduleName "
45+ path = @ (" swaggerci/$modulePath " )
46+ readmeMd = @ ($rd )
47+ artifacts = @ (" swaggerci/$modulePath /bin/Az.$moduleName .0.1.0.nupkg" )
48+ installInstructions = @ {full = " Please download the package through the curl command '$downloadCmd ', and then you could have a try locally." }
49+ result = " succeeded"
50+ }
51+ $packages += $package
52+ } catch {
53+ $package = @ {
54+ packageName = " Az.$moduleName "
55+ path = @ (" swaggerci/$modulePath " )
56+ readmeMd = @ ($rd )
57+ result = " warning"
58+ }
59+ $packages += $package
60+ }
61+ }
62+
63+ $result = @ {
64+ packages = $packages
65+ }
66+
67+ $result | ConvertTo-Json - Depth 5 | Out-File - Path $ResultFilePath
68+ }
69+
70+ Export-ModuleMember - Function Invoke-SwaggerCI
0 commit comments