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

Dev 178 #186

Merged
merged 8 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
staging
docfx/matrix.md
docfx/metadata-report.md
docfx/metadata-report.md
1 change: 1 addition & 0 deletions docfx/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions docfx/metadata-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Metadata Report of Samples
Binary file modified docfx/plugins/DocFx.Plugin.ExtractFrontMatter.dll
Binary file not shown.
Binary file modified docfx/plugins/DocFx.Plugin.ExtractFrontMatter.pdb
Binary file not shown.
123 changes: 123 additions & 0 deletions docfx/report-metadata.ps1
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions docfx/templates/material/styles/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 */
202 changes: 118 additions & 84 deletions scripts/_template-script-submission/assets/template.sample.json
Original file line number Diff line number Diff line change
@@ -1,85 +1,119 @@
[
{
"name": "<foldername>",
"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"
}
],
"categories": [
"Modernize",
"Data",
"Deploy",
"Provision",
"Configure",
"Report"
],
"tags":[
"bash",
"classic"
],
"thumbnails": [
{
"type": "image",
"order": 100,
"url": "<foldername>/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": ""
}
]
}
]
{
"name": "<foldername>",
"source": "pnp",
"title": "<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/"
}
]
}
]
2 changes: 1 addition & 1 deletion scripts/aad-analyze-user-profile-photos/assets/sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/powerapps-bulk-useraccess/assets/sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"metadata": [
{
"key": "powerapps-ps",
"key": "powerapps-powershell",
"value": "2.0.0"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"metadata": [
{
"key": "powerapps-ps",
"key": "powerapps-powershell",
"value": "2.0.0"
}
],
Expand Down