-
Couldn't load subscription status.
- Fork 0
Enhance license header script and update README #2
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -46,7 +46,7 @@ | |||||||||
| Team: Clinical Informatics & Advanced Analytics | ||||||||||
| Email: Kyle.Coder@va.gov | ||||||||||
| Created: July 24, 2025 | ||||||||||
| Version: 1.0.0 | ||||||||||
| Version: 1.0.1 | ||||||||||
|
|
||||||||||
| VA Compliance: | ||||||||||
| - No administrator privileges required | ||||||||||
|
|
@@ -61,13 +61,22 @@ | |||||||||
| [CmdletBinding()] | ||||||||||
| param( | ||||||||||
| [Parameter(Mandatory = $false, HelpMessage = 'File extensions to process')] | ||||||||||
| [string]$FileTypes = 'ps1,sql,js,css,html', | ||||||||||
| [string]$FileTypes = 'ps1,sql,js,css,html,md,txt,bat,psm,json', | ||||||||||
|
|
||||||||||
| [Parameter(Mandatory = $false, HelpMessage = 'Skip files that already have headers')] | ||||||||||
| [switch]$SkipExisting, | ||||||||||
|
|
||||||||||
| [Parameter(Mandatory = $false, HelpMessage = 'Show changes without applying them')] | ||||||||||
| [switch]$DryRun | ||||||||||
| [switch]$DryRun, | ||||||||||
|
|
||||||||||
| # Metadata to inject into headers (auto-detected if omitted) | ||||||||||
| [Parameter(Mandatory = $false)] [string]$AuthorName, | ||||||||||
| [Parameter(Mandatory = $false)] [string]$Email, | ||||||||||
| [Parameter(Mandatory = $false)] [string]$Organization, | ||||||||||
| [Parameter(Mandatory = $false)] [string]$Team, | ||||||||||
| [Parameter(Mandatory = $false)] [string]$ProjectName, | ||||||||||
| [Parameter(Mandatory = $false)] [string]$LicenseType = 'Apache-2.0', | ||||||||||
| [Parameter(Mandatory = $false)] [string]$ComplianceNote = 'Internal Use Only' | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| # Script initialization | ||||||||||
|
|
@@ -83,96 +92,105 @@ if (-not (Test-Path $LogPath)) { | |||||||||
| New-Item -ItemType Directory -Path $LogPath -Force | Out-Null | ||||||||||
| } | ||||||||||
|
|
||||||||||
| # License header templates | ||||||||||
| # Helper: attempt to read Git config (if available) | ||||||||||
| function Get-GitConfigValue { | ||||||||||
| param([Parameter(Mandatory=$true)][string]$Key) | ||||||||||
| try { | ||||||||||
| $git = Get-Command git -ErrorAction SilentlyContinue | ||||||||||
| if ($null -eq $git) { return $null } | ||||||||||
| $val = git config --get $Key 2>$null | ||||||||||
| if ([string]::IsNullOrWhiteSpace($val)) { return $null } | ||||||||||
| return $val.Trim() | ||||||||||
| } catch { return $null } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| # Auto-detect metadata if not provided | ||||||||||
| if (-not $AuthorName -or [string]::IsNullOrWhiteSpace($AuthorName)) { $AuthorName = (Get-GitConfigValue 'user.name'); if (-not $AuthorName) { $AuthorName = $env:USERNAME } } | ||||||||||
| if (-not $Email -or [string]::IsNullOrWhiteSpace($Email)) { $Email = (Get-GitConfigValue 'user.email'); if (-not $Email) { $Email = '' } } | ||||||||||
| if (-not $Organization) { $Organization = '' } | ||||||||||
| if (-not $Team) { $Team = '' } | ||||||||||
| if (-not $ProjectName -or [string]::IsNullOrWhiteSpace($ProjectName)) { $ProjectName = Split-Path -Leaf (Split-Path -Parent $ScriptPath) } | ||||||||||
| if (-not $LicenseType) { $LicenseType = 'Apache-2.0' } | ||||||||||
| if (-not $ComplianceNote) { $ComplianceNote = 'Internal Use Only' } | ||||||||||
|
|
||||||||||
| # License header templates (generic, populated with the user's info) | ||||||||||
| $LicenseHeaders = @{ | ||||||||||
| 'ps1' = @" | ||||||||||
| <# | ||||||||||
| * VA Power Platform Development | ||||||||||
| * Project: $ProjectName | ||||||||||
| * Author: $AuthorName | ||||||||||
| * Organization: $Organization | ||||||||||
| * Team: $Team | ||||||||||
| * Email: $Email | ||||||||||
| * | ||||||||||
| * Author: Kyle J. Coder | ||||||||||
| * Organization: Edward Hines Jr. VA Hospital (Hines VAMC) | ||||||||||
| * Team: Clinical Informatics & Advanced Analytics | ||||||||||
| * Email: Kyle.Coder@va.gov | ||||||||||
| * | ||||||||||
| * This file is part of the VA Power Platform workspace template. | ||||||||||
| * Licensed under MIT License - see LICENSE file for details. | ||||||||||
| * | ||||||||||
| * VA Compliance: No PHI/ePHI, Internal Use Only | ||||||||||
| * Licensed under $LicenseType - see LICENSE file for details. | ||||||||||
| * Compliance: $ComplianceNote | ||||||||||
| * Created: $(Get-Date -Format 'yyyy-MM-dd') | ||||||||||
| * Generated by Add-LicenseHeaders.ps1 | ||||||||||
| #> | ||||||||||
|
|
||||||||||
| "@ | ||||||||||
|
|
||||||||||
| 'sql' = @" | ||||||||||
| /* | ||||||||||
| * VA Power Platform Development | ||||||||||
| * | ||||||||||
| * Author: Kyle J. Coder | ||||||||||
| * Organization: Edward Hines Jr. VA Hospital (Hines VAMC) | ||||||||||
| * Team: Clinical Informatics & Advanced Analytics | ||||||||||
| * Email: Kyle.Coder@va.gov | ||||||||||
| * Project: $ProjectName | ||||||||||
| * Author: $AuthorName | ||||||||||
| * Organization: $Organization | ||||||||||
| * Team: $Team | ||||||||||
| * Email: $Email | ||||||||||
| * | ||||||||||
| * This file is part of the VA Power Platform workspace template. | ||||||||||
| * Licensed under MIT License - see LICENSE file for details. | ||||||||||
| * | ||||||||||
| * VA Database: VhaCdwDwhSql33.vha.med.va.gov | ||||||||||
| * Target Database: D03_VISN12Collab | ||||||||||
| * Classification: Internal Use Only, No PHI/ePHI | ||||||||||
| * Licensed under $LicenseType - see LICENSE file for details. | ||||||||||
| * Compliance: $ComplianceNote | ||||||||||
| * Created: $(Get-Date -Format 'yyyy-MM-dd') | ||||||||||
| * Generated by Add-LicenseHeaders.ps1 | ||||||||||
| */ | ||||||||||
|
|
||||||||||
| "@ | ||||||||||
|
|
||||||||||
| 'js' = @" | ||||||||||
| /** | ||||||||||
| * VA Power Platform Development | ||||||||||
| * | ||||||||||
| * @author Kyle J. Coder | ||||||||||
| * @organization Edward Hines Jr. VA Hospital (Hines VAMC) | ||||||||||
| * @team Clinical Informatics & Advanced Analytics | ||||||||||
| * @email Kyle.Coder@va.gov | ||||||||||
| * Project: $ProjectName | ||||||||||
| * @author $AuthorName | ||||||||||
| * @organization $Organization | ||||||||||
| * @team $Team | ||||||||||
| * @email $Email | ||||||||||
| * | ||||||||||
| * This file is part of the VA Power Platform workspace template. | ||||||||||
| * Licensed under MIT License - see LICENSE file for details. | ||||||||||
| * | ||||||||||
| * VA Compliance: Section 508 accessible, Internal Use Only | ||||||||||
| * Licensed under $LicenseType - see LICENSE file for details. | ||||||||||
| * Compliance: $ComplianceNote | ||||||||||
| * Created: $(Get-Date -Format 'yyyy-MM-dd') | ||||||||||
| * Generated by Add-LicenseHeaders.ps1 | ||||||||||
| */ | ||||||||||
|
|
||||||||||
| "@ | ||||||||||
|
|
||||||||||
| 'css' = @" | ||||||||||
| /* | ||||||||||
| * VA Power Platform Development | ||||||||||
| * | ||||||||||
| * Author: Kyle J. Coder | ||||||||||
| * Organization: Edward Hines Jr. VA Hospital (Hines VAMC) | ||||||||||
| * Team: Clinical Informatics & Advanced Analytics | ||||||||||
| * Email: Kyle.Coder@va.gov | ||||||||||
| * Project: $ProjectName | ||||||||||
| * Author: $AuthorName | ||||||||||
| * Organization: $Organization | ||||||||||
| * Team: $Team | ||||||||||
| * Email: $Email | ||||||||||
| * | ||||||||||
| * This file is part of the VA Power Platform workspace template. | ||||||||||
| * Licensed under MIT License - see LICENSE file for details. | ||||||||||
| * | ||||||||||
| * VA Branding: Official colors and accessibility compliance | ||||||||||
| * Licensed under $LicenseType - see LICENSE file for details. | ||||||||||
| * Compliance: $ComplianceNote | ||||||||||
| * Created: $(Get-Date -Format 'yyyy-MM-dd') | ||||||||||
| * Generated by Add-LicenseHeaders.ps1 | ||||||||||
| */ | ||||||||||
|
|
||||||||||
| "@ | ||||||||||
|
|
||||||||||
| 'html' = @" | ||||||||||
| <!-- | ||||||||||
| * VA Power Platform Development | ||||||||||
| * | ||||||||||
| * Author: Kyle J. Coder | ||||||||||
| * Organization: Edward Hines Jr. VA Hospital (Hines VAMC) | ||||||||||
| * Team: Clinical Informatics & Advanced Analytics | ||||||||||
| * Email: Kyle.Coder@va.gov | ||||||||||
| * | ||||||||||
| * This file is part of the VA Power Platform workspace template. | ||||||||||
| * Licensed under MIT License - see LICENSE file for details. | ||||||||||
| * Project: $ProjectName | ||||||||||
| * Author: $AuthorName | ||||||||||
| * Organization: $Organization | ||||||||||
| * Team: $Team | ||||||||||
| * Email: $Email | ||||||||||
| * | ||||||||||
| * VA Compliance: Section 508 accessible, Internal Use Only | ||||||||||
| * Licensed under $LicenseType - see LICENSE file for details. | ||||||||||
| * Compliance: $ComplianceNote | ||||||||||
| * Created: $(Get-Date -Format 'yyyy-MM-dd') | ||||||||||
| * Generated by Add-LicenseHeaders.ps1 | ||||||||||
| --> | ||||||||||
|
|
||||||||||
| "@ | ||||||||||
|
|
@@ -206,10 +224,12 @@ function Test-ExistingHeader { | |||||||||
| $ContentText = $Content -join "`n" | ||||||||||
|
|
||||||||||
| # Check for existing license indicators | ||||||||||
| return ($ContentText -match 'Kyle J\. Coder' -or | ||||||||||
| $ContentText -match 'Edward Hines Jr\. VA Hospital' -or | ||||||||||
| $ContentText -match 'MIT License' -or | ||||||||||
| $ContentText -match 'VA Power Platform Development') | ||||||||||
| return ( | ||||||||||
| $ContentText -match 'Licensed under .+ - see LICENSE file' -or | ||||||||||
| $ContentText -match 'Generated by Add-LicenseHeaders\.ps1' -or | ||||||||||
| $ContentText -match '(^/\*.*?(Licensed under|Copyright).*?\*/)' -or # block comment with license | ||||||||||
| $ContentText -match '(^<#.*?(Licensed under|Copyright).*?#>)' # ps1 block comment with license | ||||||||||
|
Comment on lines
+230
to
+231
|
||||||||||
| $ContentText -match '(^/\*.*?(Licensed under|Copyright).*?\*/)' -or # block comment with license | |
| $ContentText -match '(^<#.*?(Licensed under|Copyright).*?#>)' # ps1 block comment with license | |
| $ContentText -match '(?m)^/\*.*?(Licensed under|Copyright).*?\*/' -or # block comment with license | |
| $ContentText -match '(?m)^<#.*?(Licensed under|Copyright).*?#>' # ps1 block comment with license |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These auto-detection lines are difficult to read and maintain due to complex nested conditionals on single lines. Consider refactoring into a helper function or breaking into multiple lines for better readability.