Skip to content
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
13 changes: 13 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
Comment thread
jkdevito marked this conversation as resolved.
"version": 1,
"isRoot": true,
"tools": {
"husky": {
"version": "0.9.1",
"commands": [
"husky"
],
"rollForward": false
}
}
}
45 changes: 0 additions & 45 deletions .github/scripts/GenerateVersionNumber.ps1

This file was deleted.

114 changes: 114 additions & 0 deletions .github/scripts/Update-ReadmeBadges.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<#
.SYNOPSIS
Syncs the README .NET and PepperDash Essentials badges with the project files.
.PARAMETER Check
Exit 1 if the README badges are stale instead of rewriting them.
.PARAMETER Stage
git add README.md when it was changed.
#>
[CmdletBinding()]
param(
[switch]$Check,
[switch]$Stage
)

$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
$srcDir = Join-Path $root 'src'
$readmePath = Join-Path $root 'README.md'
$utf8 = New-Object System.Text.UTF8Encoding($false)

function Fail($message) {
[Console]::Error.WriteLine("badges: $message")
exit 1
}

# Staging README.md adds its whole working-tree copy, and badges are computed from working-tree
# sources, so refuse to run when any of those inputs differ from the index.
if ($Stage) {
# Porcelain XY: a non-blank Y is a worktree change ('??' = untracked), which the index lacks.
$status = @(git -C $root status --porcelain --untracked-files=all -- README.md 'src/*.4Series.csproj' 'src/*Factory.cs')
if ($LASTEXITCODE) { Fail 'git status failed' }
$unstaged = @($status | Where-Object { $_ -match '^.[^ ]' })
if ($unstaged.Count -gt 0) {
Fail ("unstaged or untracked badge inputs ($(($unstaged | ForEach-Object { $_.Substring(3) }) -join ', ')); stage or stash them, then commit again")
}
}

# Target framework from the 4Series csproj
$csprojFile = Get-ChildItem -Path $srcDir -Filter '*.4Series.csproj' | Select-Object -First 1
if (-not $csprojFile) { Fail 'no *.4Series.csproj found in src/' }
$csproj = [System.IO.File]::ReadAllText($csprojFile.FullName, $utf8)
$tfmMatch = [regex]::Match($csproj, '<TargetFramework>\s*([^<\s]+)\s*</TargetFramework>')
if (-not $tfmMatch.Success) { Fail "TargetFramework not found in $($csprojFile.Name)" }
$tfm = $tfmMatch.Groups[1].Value

# Minimum Essentials version: highest MinimumEssentialsFrameworkVersion across factories
$minVersions = @()
foreach ($file in Get-ChildItem -Path $srcDir -Filter '*Factory.cs') {
$text = [System.IO.File]::ReadAllText($file.FullName, $utf8)
$found = [regex]::Matches($text, '(?m)^\s*MinimumEssentialsFrameworkVersion\s*=\s*"(\d+(?:\.\d+)+)"\s*;')
foreach ($m in $found) { $minVersions += $m.Groups[1].Value }
}
if ($minVersions.Count -eq 0) { Fail 'MinimumEssentialsFrameworkVersion not found in src/*Factory.cs' }
$minVersion = ($minVersions | Sort-Object { [version]$_ } | Select-Object -Last 1)

# Warn when the NuGet reference and the factory minimum disagree
$pkgMatch = [regex]::Match($csproj, '<PackageReference\s+Include="PepperDashEssentials"\s+Version="([^"]+)"')
if ($pkgMatch.Success -and $pkgMatch.Groups[1].Value -ne $minVersion) {
Write-Warning "badges: PepperDashEssentials package $($pkgMatch.Groups[1].Value) != MinimumEssentialsFrameworkVersion $minVersion"
}

function Get-FrameworkBadge($moniker) {
$legacy = [regex]::Match($moniker, '^net(\d)(\d)(\d)?$')
if ($legacy.Success) {
$parts = @($legacy.Groups[1].Value, $legacy.Groups[2].Value)
if ($legacy.Groups[3].Success) { $parts += $legacy.Groups[3].Value }
return @{ Label = '.NET Framework'; Message = ($parts -join '.') }
}
$modern = [regex]::Match($moniker, '^net(\d+\.\d+)')
if ($modern.Success) { return @{ Label = '.NET'; Message = $modern.Groups[1].Value } }
return @{ Label = '.NET'; Message = $moniker }
}

# shields.io static badge path: '-' and '_' are escaped by doubling, spaces as %20
function Format-Segment($s) { $s.Replace('-', '--').Replace('_', '__').Replace(' ', '%20') }
function Get-BadgeUrl($label, $message, $color) {
'https://img.shields.io/badge/{0}-{1}-{2}' -f (Format-Segment $label), (Format-Segment $message), $color
}

$fw = Get-FrameworkBadge $tfm
$essentialsMessage = '{0} v{1}' -f [char]0x2265, $minVersion
$replacements = @(
@{
Pattern = '!\[\.NET[^\]]*\]\(https://img\.shields\.io/badge/[^)]*\)'
Value = '![.NET](' + (Get-BadgeUrl $fw.Label $fw.Message '512BD4') + ')'
},
@{
Pattern = '!\[PepperDash Essentials\]\(https://img\.shields\.io/badge/[^)]*\)'
Value = '![PepperDash Essentials](' + (Get-BadgeUrl 'PepperDash Essentials' $essentialsMessage 'blue') + ')'
}
)

$original = [System.IO.File]::ReadAllText($readmePath, $utf8)
$updated = $original
foreach ($r in $replacements) {
if (-not [regex]::IsMatch($updated, $r.Pattern)) { Fail "badge not found in README.md: $($r.Pattern)" }
$value = $r.Value
$updated = [regex]::Replace($updated, $r.Pattern, { param($m) $value }, 'None')
}

if ($updated -ceq $original) {
Write-Host 'badges: README.md up to date'
exit 0
}

if ($Check) { Fail 'README.md badges are stale; run .github/scripts/Update-ReadmeBadges.ps1' }

[System.IO.File]::WriteAllText($readmePath, $updated, $utf8)
Write-Host "badges: README.md updated ($($fw.Label) $($fw.Message), Essentials >= v$minVersion)"

if ($Stage) {
git -C $root add README.md
if ($LASTEXITCODE) { Fail 'git add README.md failed' }
}
40 changes: 0 additions & 40 deletions .github/scripts/UpdateAssemblyVersion.ps1

This file was deleted.

42 changes: 0 additions & 42 deletions .github/scripts/ZipBuildOutput.ps1

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,6 @@ MigrationBackup/
*.clz
*.projectinfo
*.suo

# VS Code
*.code-workspace
22 changes: 22 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

## husky task runner examples -------------------
## Note : for local installation use 'dotnet' prefix. e.g. 'dotnet husky'

## run all tasks
#husky run

### run all tasks with group: 'group-name'
#husky run --group group-name

## run task with name: 'task-name'
#husky run --name task-name

## pass hook arguments to task
#husky run --args "$1" "$2"

## or put your custom commands -------------------
#echo 'Husky.Net is awesome!'

dotnet husky run
10 changes: 10 additions & 0 deletions .husky/task-runner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://alirezanet.github.io/Husky.Net/schema.json",
"tasks": [
{
"name": "update-readme-badges",
"command": "pwsh",
"args": [ "-NoProfile", "-File", ".github/scripts/Update-ReadmeBadges.ps1", "-Stage" ]
}
]
}
22 changes: 1 addition & 21 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
{
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#8c57e5",
"activityBar.background": "#8c57e5",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#6e3411",
"activityBarBadge.foreground": "#e7e7e7",
"commandCenter.border": "#e7e7e799",
"sash.hoverBorder": "#8c57e5",
"statusBar.background": "#6e2bde",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#8c57e5",
"statusBarItem.remoteBackground": "#6e2bde",
"statusBarItem.remoteForeground": "#e7e7e7",
"titleBar.activeBackground": "#6e2bde",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#6e2bde99",
"titleBar.inactiveForeground": "#e7e7e799"
},
"peacock.color": "#6e2bde",
"[csharp]": {
"editor.defaultFormatter": "ms-dotnettools.csharp",
"editor.formatOnSave": true,
Expand All @@ -29,4 +9,4 @@
"csharp.inlayHints.enableInlayHintsForLambdaParameterTypes": true,
"csharp.inlayHints.enableInlayHintsForTypes": true,
"dotnet.formatting.organizeImportsOnFormat": true
}
}
24 changes: 24 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Install git hooks",
"type": "shell",
"command": "dotnet tool restore && dotnet husky install",
"options": {
"shell": {
"executable": "pwsh",
"args": ["-NoProfile", "-Command"]
}
},
"presentation": {
"reveal": "silent",
"close": true
},
"runOptions": {
"runOn": "folderOpen"
},
"problemMatcher": []
}
]
}
2 changes: 0 additions & 2 deletions GetPackages.BAT

This file was deleted.

Loading
Loading