{"id":7748121,"name":"StartAutomating/PSMinifier","ecosystem":"actions","description":"A Miniature Minifier For PowerShell","homepage":null,"licenses":"mit","normalized_licenses":["MIT"],"repository_url":"https://github.com/StartAutomating/PSMinifier","keywords_array":[],"namespace":"StartAutomating","versions_count":5,"first_release_published_at":"2021-03-16T03:55:47.000Z","latest_release_published_at":"2022-07-09T00:36:46.000Z","latest_release_number":"v1.1.4","last_synced_at":"2026-03-19T08:34:23.807Z","created_at":"2023-05-17T11:40:24.969Z","updated_at":"2026-03-19T08:34:23.808Z","registry_url":"https://github.com/StartAutomating/PSMinifier","install_command":null,"documentation_url":null,"metadata":{"name":"PSMinifier","description":"A Miniature Minifier For PowerShell","inputs":{"Include":{"required":false,"description":"One or more wildcards of files to include.\nIf not provided, all .ps1 in a workspace will be included.\n"},"Exclude":{"required":false,"default":"\"*.*.ps1\"","description":"One or more wildcards of files to exclude."},"GZip":{"required":false,"description":"If set, the minified content will be encoded as GZip, further reducing it's size."},"NoBlock":{"required":false,"description":"If set, zipped minified content will be encoded without blocks, making it a very long single line.\nThis parameter is only valid with -GZip.\n"},"CommitMessage":{"required":false,"description":"If provided, will commit changes made to the workspace with this commit message."},"UserEmail":{"required":false,"description":"The user email associated with a git commit."},"UserName":{"required":false,"description":"The user name associated with a git commit."}},"branding":{"icon":"minimize","color":"blue"},"outputs":{"OriginalSize":{"description":"The Original Size of all files","value":"${{steps.PSMinifier.outputs.OriginalSize}}"},"MinifiedSize":{"description":"The Total Size of all minified files","value":"${{steps.PSMinifier.outputs.MinifiedSize}}"},"MinifiedPercent":{"description":"The Percentage Saved by minifying","value":"${{steps.PSMinifier.outputs.MinifiedPercent}}"}},"runs":{"using":"composite","steps":[{"name":"PSMinifier","id":"PSMinifier","shell":"pwsh","env":{"CommitMessage":"${{inputs.CommitMessage}}","NoBlock":"${{inputs.NoBlock}}","UserEmail":"${{inputs.UserEmail}}","GZip":"${{inputs.GZip}}","Exclude":"${{inputs.Exclude}}","Include":"${{inputs.Include}}","UserName":"${{inputs.UserName}}"},"run":"$Parameters = @{}\n$Parameters.Include = ${env:Include}\n$Parameters.Include = $parameters.Include -split ';' -replace '^[''\"]' -replace  '[''\"]$'\n$Parameters.Exclude = ${env:Exclude}\n$Parameters.Exclude = $parameters.Exclude -split ';' -replace '^[''\"]' -replace  '[''\"]$'\n$Parameters.GZip = ${env:GZip}\n$Parameters.GZip = $parameters.GZip -match 'true';\n$Parameters.NoBlock = ${env:NoBlock}\n$Parameters.NoBlock = $parameters.NoBlock -match 'true';\n$Parameters.CommitMessage = ${env:CommitMessage}\n$Parameters.UserEmail = ${env:UserEmail}\n$Parameters.UserName = ${env:UserName}\nforeach ($k in @($parameters.Keys)) {\n    if ([String]::IsNullOrEmpty($parameters[$k])) {\n        $parameters.Remove($k)\n    }\n}\nWrite-Host \"::debug:: PSMinifier $(@(foreach ($p in $Parameters.GetEnumerator()) {'-' + $p.Key + ' ' + $p.Value}) -join ' ')\"\n\u0026 {\u003c#\n.Synopsis\n    PSMinifier Action\n.Description\n    Runs PSMinifier on code in the workspace, and creates .min.ps1 files.\n#\u003e\nparam(\n# One or more wildcards of files to include.\n# If not provided, all .ps1 in a workspace will be included.\n[string[]]\n$Include,\n\n# One or more wildcards of files to exclude.\n[string[]]\n$Exclude = \"*.*.ps1\",\n\n# If set, the minified content will be encoded as GZip, further reducing it's size.\n[switch]\n$GZip,\n\n# If set, zipped minified content will be encoded without blocks, making it a very long single line.\n# This parameter is only valid with -GZip.\n[switch]\n$NoBlock,\n\n# If provided, will commit changes made to the workspace with this commit message.\n[string]\n$CommitMessage,\n\n# The user email associated with a git commit.\n[string]\n$UserEmail,\n\n# The user name associated with a git commit.\n[string]\n$UserName\n)\n\n\"::group::Parameters\" | Out-Host\n[PSCustomObject]$PSBoundParameters | Format-List | Out-Host\n\"::endgroup::\" | Out-Host\n\n@\"\n::group::GitHubEvent\n$($gitHubEvent | ConvertTo-Json -Depth 100)\n::endgroup::\n\"@ | Out-Host\n\n$PSD1Found = Get-ChildItem -Recurse -Filter \"*.psd1\" | Where-Object Name -eq 'PSMinifier.psd1' | Select-Object -First 1\n\nif ($PSD1Found) {\n    $psMinifierPath = $PSD1Found\n    Import-Module $PSD1Found -Force -PassThru | Out-Host\n}\nelseif ($env:GITHUB_ACTION_PATH) {\n    $psMinifierPath = Join-Path $env:GITHUB_ACTION_PATH 'PSMinifier.psd1'\n    if (Test-path $psMinifierPath) {\n        Import-Module $psMinifierPath -Force -PassThru | Out-String\n    } else {\n        throw \"PSMinifier not found\"\n    }\n} elseif (-not (Get-Module PSMinifier)) {\n    Get-ChildItem env: | Out-String\n    throw \"Action Path not found\"\n}\n\n\"::debug::PSMinifier Loaded from Path - $($psMinifierPath)\" | Out-Host\n\nif (-not $env:GITHUB_WORKSPACE) { throw \"No GitHub workspace\" }\nif (-not $CommitMessage -and $gitHubEvent.head_commit.message) {\n    $CommitMessage = $gitHubEvent.head_commit.message\n}\n\n$compressSplat = @{} + $PSBoundParameters\n$compressSplat.Remove('Include')\n$compressSplat.Remove('Exclude')\n$compressSplat.Remove('CommitMessage')\n$compressSplat.Remove('UserEmail')\n$compressSplat.Remove('UserName')\nif ($GZip) { $compressSplat.DotSource = $true }\n\n\"EXCLUDING $Exclude\" | Out-Host\n\n$commandsToMinify =\n    @(Get-ChildItem -LiteralPath $env:GITHUB_WORKSPACE -Filter *.ps1 |\n        Where-Object {\n            $fileInfo = $_ \n            if ($fileInfo.Name -like '*.min.*ps1') { return } # Don't overminify\n            if ($Include) {\n                foreach ($inc in $Include) {\n                    if ($fileInfo.Name -like $inc) { return $true }\n                }\n            } else { return $true }\n        } |\n        Where-Object {\n            $fileInfo = $_ \n            if ($Exclude) {\n                foreach ($ex in $Exclude) {\n                    if ($fileInfo.Name -like $ex) { return $false }\n                }\n                return $true\n            } else {\n                return $true\n            }\n        } |\n        Get-Command { $_.FullName })\n\n\n$minifiedCommands =\n    @($commandsToMinify |\n        Compress-ScriptBlock @compressSplat -OutputPath {\n            if ($GZip) {\n                $_.Source -replace '\\.ps1$', '.min.gzip.ps1'\n            } else {\n                $_.Source -replace '\\.ps1$', '.min.ps1'\n            }\n        } -PassThru)\n\"::group::Minified Commands\" | Out-Host\n$minifiedCommands | Out-Host\n\"::endgroup::\" | Out-Host\n\n\"::group::Summary\" | Out-Host\n$totalOriginal = 0 \n$totalMinified = 0 \nfor ($n =0 ; $n -lt $commandsToMinify.Length; $n++) {\n    $safeName = $commandsToMinify[$n].Name -replace '\\W'\n    $originalSize = ([IO.FileInfo]$($commandsToMinify[$n].Source)).Length\n    $totalOriginal+=$originalSize\n    $minifiedSize = $minifiedCommands[$n].Length\n    $totalMinified = $minifiedSize\n    $minifiedPercent = $minifiedCommands[$n].Length / $originalSize\n    \"$($commandsToMinify[$n].name) -\u003e $($minifiedCommands[$n].Name) - $([Math]::Round($minifiedPercent * 100, 2))%\" | Out-Host\n    \"::set-output name=$($safeName)_MinifiedSize::$minifiedSize\"       | Out-Host\n    \"::set-output name=$($safeName)_MinifiedPercent::$minifiedPercent\" | Out-Host\n}\n\"Total Original Size: $([Math]::Round(($totalOriginal /1kb),2))kb\"     | Out-Host\n\"::set-output name=OriginalSize::$totalOriginal\"                       | Out-Host\n\"::set-output name=MinifiedSize::$totalMinified\"                       | Out-Host\n\"::set-output name=MinifiedPercent::$($totalOriginal / $totalMinified)\"| Out-Host\n\"Total Minified Size: $([Math]::Round(($totalMinified /1kb),2))kb\"     | Out-Host\n\n\"::endgroup::\" | Out-Host\n\nif ($CommitMessage -and $minifiedCommands) {\n    if (-not $UserName) { $UserName = $env:GITHUB_ACTOR }\n    if (-not $UserEmail) { $UserEmail = \"$UserName@github.com\" }\n    git config --global user.email $UserEmail\n    git config --global user.name  $UserName\n\n    $filesUpdated = 0\n    $minifiedCommands |\n        ForEach-Object {\n            $gitStatusOutput = git status $_.Fullname -s\n            if ($gitStatusOutput) {\n                git add $_.Fullname\n                $filesUpdated++\n            } else {\n                \"No need to Commit $($_.FullName)\" | Out-Host\n            }\n        }\n\n    if ($filesUpdated) {\n        $ErrorActionPreference = 'continue'\n        $gitPushed =  git push 2\u003e\u00261\n        \"Git Push Output: $($gitPushed  | Out-String)\"\n        $LASTEXITCODE = 0\n        exit 0        \n    } else {\n        \"Nothing to Push\" | Out-Host\n    }\n}} @Parameters\n"}]},"default_branch":"master","path":null},"repo_metadata":{"uuid":"235255442","full_name":"StartAutomating/PSMinifier","owner":"StartAutomating","description":"A Miniature Minifier For PowerShell","archived":false,"fork":false,"pushed_at":"2022-07-09T00:37:38.000Z","size":113,"stargazers_count":17,"open_issues_count":3,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2023-07-14T08:50:14.924Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StartAutomating.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-21T04:25:51.000Z","updated_at":"2023-06-02T09:14:56.000Z","dependencies_parsed_at":"2023-01-11T17:22:12.353Z","dependency_job_id":null,"html_url":"https://github.com/StartAutomating/PSMinifier","commit_stats":null,"previous_names":[],"tags_count":5,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StartAutomating%2FPSMinifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StartAutomating%2FPSMinifier/tags","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StartAutomating%2FPSMinifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StartAutomating","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":145726914,"owners_count":6281108,"icon_url":"https://github.com/github.png","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"},"owner_record":{"login":"StartAutomating","name":"James Brundage","uuid":"1043665","kind":"user","description":"","email":"","website":"http://start-automating.com/","location":"Seattle, WA","twitter":"jamesbru","company":"Start-Automating","icon_url":"https://avatars.githubusercontent.com/u/1043665?u=38888051372474754f0b622ada16d87ce69227ca\u0026v=4","repositories_count":39,"last_synced_at":"2023-02-24T13:57:29.796Z","metadata":{"has_sponsors_listing":false},"html_url":"https://github.com/StartAutomating","created_at":"2022-11-08T04:14:46.274Z","updated_at":"2023-02-24T13:57:29.798Z","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StartAutomating","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StartAutomating/repositories"},"tags":[{"name":"v1.1.4","sha":"6d9f510d8171d4985fbc6f4998960404e0a1741e","kind":"tag","published_at":"2022-07-09T00:36:46.000Z","download_url":"https://codeload.github.com/StartAutomating/PSMinifier/tar.gz/v1.1.4","html_url":"https://github.com/StartAutomating/PSMinifier/releases/tag/v1.1.4","dependencies_parsed_at":"2023-05-30T20:21:56.926Z","dependency_job_id":null,"tag_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StartAutomating%2FPSMinifier/tags/v1.1.4","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StartAutomating%2FPSMinifier/tags/v1.1.4/manifests"},{"name":"v1.1.3","sha":"d1f3c57984ab5cd7f919ae00c8e36456869da43a","kind":"tag","published_at":"2021-11-07T22:11:47.000Z","download_url":"https://codeload.github.com/StartAutomating/PSMinifier/tar.gz/v1.1.3","html_url":"https://github.com/StartAutomating/PSMinifier/releases/tag/v1.1.3","dependencies_parsed_at":"2023-05-30T20:21:57.289Z","dependency_job_id":null,"tag_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StartAutomating%2FPSMinifier/tags/v1.1.3","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StartAutomating%2FPSMinifier/tags/v1.1.3/manifests"},{"name":"v1.1.2","sha":"d375bc59346d0aa56c790c0233a86669e7eace10","kind":"tag","published_at":"2021-09-28T04:07:35.000Z","download_url":"https://codeload.github.com/StartAutomating/PSMinifier/tar.gz/v1.1.2","html_url":"https://github.com/StartAutomating/PSMinifier/releases/tag/v1.1.2","dependencies_parsed_at":"2023-05-30T20:21:57.551Z","dependency_job_id":null,"tag_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StartAutomating%2FPSMinifier/tags/v1.1.2","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StartAutomating%2FPSMinifier/tags/v1.1.2/manifests"},{"name":"v1.1.1","sha":"e679bbe42e30139a28a41d44a8c01d8798fcf3b1","kind":"tag","published_at":"2021-09-26T02:23:53.000Z","download_url":"https://codeload.github.com/StartAutomating/PSMinifier/tar.gz/v1.1.1","html_url":"https://github.com/StartAutomating/PSMinifier/releases/tag/v1.1.1","dependencies_parsed_at":"2023-05-30T20:21:58.457Z","dependency_job_id":null,"tag_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StartAutomating%2FPSMinifier/tags/v1.1.1","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StartAutomating%2FPSMinifier/tags/v1.1.1/manifests"},{"name":"v1.1","sha":"30609f284bd422681b9a7b488bd39247c57617de","kind":"tag","published_at":"2021-03-16T03:55:47.000Z","download_url":"https://codeload.github.com/StartAutomating/PSMinifier/tar.gz/v1.1","html_url":"https://github.com/StartAutomating/PSMinifier/releases/tag/v1.1","dependencies_parsed_at":"2023-05-30T20:21:58.939Z","dependency_job_id":null,"tag_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StartAutomating%2FPSMinifier/tags/v1.1","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StartAutomating%2FPSMinifier/tags/v1.1/manifests"}]},"repo_metadata_updated_at":"2023-07-14T10:29:51.103Z","dependent_packages_count":0,"downloads":null,"downloads_period":null,"dependent_repos_count":1,"rankings":{"downloads":null,"dependent_repos_count":24.775788306132153,"dependent_packages_count":0.0,"stargazers_count":8.10014260814451,"forks_count":16.162256377753128,"docker_downloads_count":null,"average":12.259546823007447},"purl":"pkg:githubactions/StartAutomating/PSMinifier","advisories":[],"docker_usage_url":"https://docker.ecosyste.ms/usage/actions/StartAutomating/PSMinifier","docker_dependents_count":null,"docker_downloads_count":null,"usage_url":"https://repos.ecosyste.ms/usage/actions/StartAutomating/PSMinifier","dependent_repositories_url":"https://repos.ecosyste.ms/api/v1/usage/actions/StartAutomating/PSMinifier/dependencies","status":null,"funding_links":[],"critical":null,"issue_metadata":null,"versions_url":"https://packages.ecosyste.ms/api/v1/registries/github%20actions/packages/StartAutomating%2FPSMinifier/versions","version_numbers_url":"https://packages.ecosyste.ms/api/v1/registries/github%20actions/packages/StartAutomating%2FPSMinifier/version_numbers","dependent_packages_url":"https://packages.ecosyste.ms/api/v1/registries/github%20actions/packages/StartAutomating%2FPSMinifier/dependent_packages","related_packages_url":"https://packages.ecosyste.ms/api/v1/registries/github%20actions/packages/StartAutomating%2FPSMinifier/related_packages","codemeta_url":"https://packages.ecosyste.ms/api/v1/registries/github%20actions/packages/StartAutomating%2FPSMinifier/codemeta","maintainers":[]}