diff --git a/.gitignore b/.gitignore index eef790fd3..abde7d5fc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ staging docfx/matrix.md +docfx/metadata-report.md +docfx/metadata-report.md diff --git a/docfx/build.ps1 b/docfx/build.ps1 index 02ff54fcc..e7c1fe3a4 100644 --- a/docfx/build.ps1 +++ b/docfx/build.ps1 @@ -4,6 +4,7 @@ $ErrorActionPreference = "Stop" Set-StrictMode -Version 2.0 ./main/docfx/report-matrix.ps1 -BaseDir "./main" -ReportFile "./main/docfx/matrix.md" +./main/docfx/report-metadata.ps1 -BaseDir "./main" -ReportFile "./main/docfx/metadata-report.md" docfx build ./main/docfx/docfx.json --warningsAsErrors $args diff --git a/docfx/metadata-report.md b/docfx/metadata-report.md new file mode 100644 index 000000000..2e6baf1f2 --- /dev/null +++ b/docfx/metadata-report.md @@ -0,0 +1 @@ +# Metadata Report of Samples diff --git a/docfx/plugins/DocFx.Plugin.ExtractFrontMatter.dll b/docfx/plugins/DocFx.Plugin.ExtractFrontMatter.dll index d799857a1..d54d0431e 100644 Binary files a/docfx/plugins/DocFx.Plugin.ExtractFrontMatter.dll and b/docfx/plugins/DocFx.Plugin.ExtractFrontMatter.dll differ diff --git a/docfx/plugins/DocFx.Plugin.ExtractFrontMatter.pdb b/docfx/plugins/DocFx.Plugin.ExtractFrontMatter.pdb index 68bdf20b2..1e070f679 100644 Binary files a/docfx/plugins/DocFx.Plugin.ExtractFrontMatter.pdb and b/docfx/plugins/DocFx.Plugin.ExtractFrontMatter.pdb differ diff --git a/docfx/report-metadata.ps1 b/docfx/report-metadata.ps1 new file mode 100644 index 000000000..8c9baacfb --- /dev/null +++ b/docfx/report-metadata.ps1 @@ -0,0 +1,123 @@ +# Script for reporting the information from the samples + +## Variables +param( + [string]$BaseDir = "C:\Git\contrib\script-samples\", + [string]$ScriptFolder = "scripts", + [string]$ReportFile = "metadata-report.md", + [string]$AssetsFolder = "assets" +) + +function DispTick{ + return "`u{1F44D}" +} + +function DispNope{ + return "`u{1F937}" +} + +function ResolveLink{ + param ( + [string] + $Link + ) + + $markdownLink = "../scripts/{0}/README.md" -f $Link + return $markdownLink +} + +function GetJsonFromSampleJson{ + param( + [string]$SamplePath, + [string]$DefaultReturn + ) + + try{ + $assetsFolder = Join-Path -Path $SamplePath -ChildPath $AssetsFolder + $sampleFilePath = Join-Path -Path $assetsFolder -ChildPath "sample.json" + + $json = Get-Content $sampleFilePath | ConvertFrom-Json + + return $json + + }catch{ + # Swallow - this shouldnt happen + Write-Host "Warning cannot resolve json: $PSItem.Message" + } + + return $DefaultReturn +} + +# Check all pages for tabs and three *** + +$dir = Join-Path -Path $BaseDir -ChildPath $ScriptFolder + +$files = Get-ChildItem -Path $dir -Recurse -Include README.md + +Write-Host "$($files.Length) found" + +"# Metadata Report of Samples" | Out-File $ReportFile -Force +"| Sample | Products | Categories | Tags | Metadata | Image URL | Source Credit | Reference Count |" | Out-File $reportFile -Append +"|--------|:--------:|:----------:|:----:|:--------:|:---------:|:-------------:|:---------------:|" | Out-File $reportFile -Append + +$matrixRows = @() +$sampleCount = 0 + +$files | Foreach-Object { + + # Skip these + if($_.Directory.Name -eq "scripts" -or + $_.Directory.Name -eq "_template-script-submission"){ + return + } + + $sampleJsonObj = GetJsonFromSampleJson -SamplePath $_.Directory -DefaultReturn $_.Directory.Name + + $content = Get-Content -Path $_.FullName -Raw + $title = $sampleJsonObj.title + $dirName = $_.Directory.Name + $imgUrl = $sampleJsonObj.thumbnails[0].url + $imgStatus = "" + $sourceCreditReference = "-" + $references = $sampleJsonObj.references + + if($imgUrl -like "https://raw.githubusercontent.com/pnp/script-samples/main/scripts/*"){ + $imgStatus = DispTick + }else{ + $imgStatus = DispNope + } + + if($content.Contains("#tab/cli-m365-ps")){ + $sourceCreditReference = DispTick + } + + $sampleCount++ + + $status = [PSCustomObject]@{ + Link = "[$($title)]($(ResolveLink $dirName))" + Description = $sampleJsonObj.shortDescription + Products = $($sampleJsonObj.products -join ', ') + Categories = $($sampleJsonObj.categories -join ', ') + Tags = $($sampleJsonObj.tags -join ', ') + Metadata = $($sampleJsonObj.metadata.key -join ', ') + ImageStatus = $imgStatus + HasSourceCredit = $sourceCreditReference + ReferenceCount = $($references.Count) + } + + $matrixRows += $status +} + +# Output Report + + +$matrixRows | ForEach-Object{ + + $row = "| {0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} |" -f $_.Link, $_.Products, $_.Categories, $_.Tags, $_.Metadata, $_.ImageStatus, $_.HasSourceCredit, $_.ReferenceCount + Write-Host $row + + $row | Out-File $reportFile -Append +} + +"`nThere are **{0}** script scenarios with metadata in the site | Generated: {1} `n`n" -f $sampleCount, [System.DateTime]::Now.ToString("dd MMM yyyy hh:mm:ss") ` + | Out-File $reportFile -Append \ No newline at end of file diff --git a/docfx/templates/material/styles/site.css b/docfx/templates/material/styles/site.css index fd479b353..803e9fde1 100644 --- a/docfx/templates/material/styles/site.css +++ b/docfx/templates/material/styles/site.css @@ -38,6 +38,7 @@ background-image: url(../assets/icons/custom/azure.svg); } +.sample-details .producttype-item.powerapps-powershell, .sample-details .producttype-item.powerapps-ps { background-image: url(../assets/icons/custom/powerapps.svg); } @@ -126,4 +127,11 @@ background-repeat: no-repeat; */ } +.sample-thumbnail[data-products^="powerapps"] .sample-preview, +.sample-thumbnail[data-products^="power apps"] .sample-preview { + background: rgb(237,237,237); + background: linear-gradient(90deg, rgba(237,237,237,1) 0%, rgba(222,126,194,1) 77%); +} + + /* //Data driven backgrounds */ \ No newline at end of file diff --git a/scripts/_template-script-submission/assets/template.sample.json b/scripts/_template-script-submission/assets/template.sample.json index 9d122e5bb..4503d2fc2 100644 --- a/scripts/_template-script-submission/assets/template.sample.json +++ b/scripts/_template-script-submission/assets/template.sample.json @@ -1,85 +1,119 @@ [ - { - "name": "", - "source": "pnp", - "title": "", - "shortDescription": "", - "url": "/README.html", - "longDescription": [ - "" - ], - "creationDateTime": "2021-05-11", - "updateDateTime": "2021-05-11", - "products": [ - "SharePoint", - "Office", - "Graph", - "PowerApps", - "Teams", - "Power Automate", - "Microsoft Todo", - "Azure" - ], - "metadata": [ - { - "key": "pnp-powerShell", - "value": "1.5.0" - }, - { - "key": "cli-for-microsoft365", - "value": "3.7.0" - }, - { - "key": "graph-powershell", - "value": "1.0.0" - }, - { - "key": "SPO-Management-Shell", - "value": "16.0.21116.12000" - }, - { - "key": "azure-cli", - "value":"2.27.0" - }, - { - "key": "microsoftteams-powershell", - "value":"3.0.0" - } - ], - "categories": [ - "Modernize", - "Data", - "Deploy", - "Provision", - "Configure", - "Report" - ], - "tags":[ - "bash", - "classic" - ], - "thumbnails": [ - { - "type": "image", - "order": 100, - "url": "/assets/preview.png", - "alt": "" - } - ], - "authors": [ - { - "gitHubAccount": "pkbullock", - "company": "CaPa Creative Ltd", - "pictureUrl": "https://avatars.githubusercontent.com/u/8781041?v=4", - "name": "Paul Bullock" - } - ], - "references": [ - { - "name": "", - "description": "", - "url": "" - } - ] - } - ] \ No newline at end of file + { + "name": "", + "source": "pnp", + "title": "", + "shortDescription": "", + "url": "<foldername>/README.html", + "longDescription": [ + "" + ], + "creationDateTime": "2021-05-11", + "updateDateTime": "2021-05-11", + "products": [ + "SharePoint", + "Office", + "Graph", + "PowerApps", + "Teams", + "Power Automate", + "Microsoft Todo", + "Azure" + ], + "metadata": [ + { + "key": "pnp-powerShell", + "value": "1.5.0" + }, + { + "key": "cli-for-microsoft365", + "value": "3.7.0" + }, + { + "key": "graph-powershell", + "value": "1.0.0" + }, + { + "key": "SPO-Management-Shell", + "value": "16.0.21116.12000" + }, + { + "key": "azure-cli", + "value":"2.27.0" + }, + { + "key": "microsoftteams-powershell", + "value":"3.0.0" + }, + { + "key": "powerapps-powershell", + "value": "2.0.0" + } + ], + "categories": [ + "Modernize", + "Data", + "Deploy", + "Provision", + "Configure", + "Report" + ], + "tags":[ + "bash", + "classic" + ], + "thumbnails": [ + { + "type": "image", + "order": 100, + "url": "https://raw.githubusercontent.com/pnp/script-samples/main/scripts/<foldername>/assets/preview.png", + "alt": "Preview of the sample <title>" + } + ], + "authors": [ + { + "gitHubAccount": "pkbullock", + "company": "CaPa Creative Ltd", + "pictureUrl": "https://github.com/pkbullock.png", + "name": "Paul Bullock" + } + ], + "references": [ + { + "name": "Want to learn more about PnP PowerShell and the cmdlets", + "description": "Check out the PnP PowerShell site to get started and for the reference to the cmdlets.", + "url": "https://aka.ms/pnp/powershell" + }, + { + "name": "Want to learn more about CLI for Microsoft 365 and the commands", + "description": "Check out the CLI for Microsoft 365 site to get started and for the reference to the commands.", + "url": "https://aka.ms/cli-m365" + }, + { + "name": "Want to learn more about Microsoft Graph PowerShell SDK and the cmdlets", + "description": "Check out the Microsoft Graph PowerShell SDK documentation site to get started and for the reference to the cmdlets.", + "url": "https://docs.microsoft.com/en-us/graph/powershell/get-started" + }, + { + "name": "Want to learn more about Power Apps PowerShell and the cmdlets", + "description": "Check out the Power Apps PowerShell documentation site to get started and for the reference to the cmdlets.", + "url": "https://docs.microsoft.com/en-us/power-platform/admin/powerapps-powershell" + }, + { + "name": "Introduction to the SharePoint Online Management Shell", + "description": "Check out the SPO Management Shell documentation site to get started and for the reference to the cmdlets.", + "url": "https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-online/introduction-sharepoint-online-management-shell?view=sharepoint-ps" + }, + { + "name": "Want to learn more about Microsoft Teams PowerShell and the cmdlets", + "description": "Check out the Microsoft Teams PowerShell documentation site to get started and for the reference to the cmdlets.", + "url": "https://docs.microsoft.com/en-us/microsoftteams/teams-powershell-overview" + }, + { + "name": "Want to learn more about Azure CLI and the commands", + "description": "Check out the Azure CLI documentation site to get started and for the reference to the commands.", + "url": "https://docs.microsoft.com/en-us/cli/azure/" + } + ] + } +] \ No newline at end of file diff --git a/scripts/aad-analyze-user-profile-photos/assets/sample.json b/scripts/aad-analyze-user-profile-photos/assets/sample.json index 13b5020ad..369743c60 100644 --- a/scripts/aad-analyze-user-profile-photos/assets/sample.json +++ b/scripts/aad-analyze-user-profile-photos/assets/sample.json @@ -32,7 +32,7 @@ { "type": "image", "order": 100, - "url": "aad-analyze-user-profile-photos/assets/preview.png", + "url": "https://raw.githubusercontent.com/pnp/script-samples/main/scripts/aad-analyze-user-profile-photos/assets/preview.png", "alt": "preview image for the sample", "slides": null } diff --git a/scripts/powerapps-bulk-useraccess/assets/sample.json b/scripts/powerapps-bulk-useraccess/assets/sample.json index c37496885..11339a1e9 100644 --- a/scripts/powerapps-bulk-useraccess/assets/sample.json +++ b/scripts/powerapps-bulk-useraccess/assets/sample.json @@ -15,7 +15,7 @@ ], "metadata": [ { - "key": "powerapps-ps", + "key": "powerapps-powershell", "value": "2.0.0" } ], diff --git a/scripts/powerapps-get-app-users-list-csv/assets/sample.json b/scripts/powerapps-get-app-users-list-csv/assets/sample.json index 0556d829e..2e138a173 100644 --- a/scripts/powerapps-get-app-users-list-csv/assets/sample.json +++ b/scripts/powerapps-get-app-users-list-csv/assets/sample.json @@ -15,7 +15,7 @@ ], "metadata": [ { - "key": "powerapps-ps", + "key": "powerapps-powershell", "value": "2.0.0" } ],