diff --git a/Add-VsCodeDatabaseConnection.ps1 b/Add-VsCodeDatabaseConnection.ps1 deleted file mode 100644 index 42eb94f..0000000 --- a/Add-VsCodeDatabaseConnection.ps1 +++ /dev/null @@ -1,91 +0,0 @@ -<# -.SYNOPSIS -Adds a VS Code MSSQL database connection to the repo. - -.DESCRIPTION -The VSCode MSSQL extension can use saved database connections to connect to for queries, -and this allows adding those to the VSCode settings in the current git repo. - -.INPUTS -Any object with these properties, used to construct a database connection entry: -* ProfileName or Name -* ServerInstance or Server or DataSource -* Database or InitialCatalog -* UserName or UID - -.FUNCTIONALITY -VSCode - -.LINK -https://marketplace.visualstudio.com/items?itemName=ms-mssql.mssql - -.LINK -Get-VSCodeSetting.ps1 - -.LINK -Set-VSCodeSetting.ps1 - -.EXAMPLE -Add-VsCodeDatabaseConnection.ps1 ConnectionName ServerName\instance DatabaseName - -Adds an MSSQL extension trusted connection named ConnectionName that -connects to the server ServerName\instance and database DatabaseName. -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([void])] Param( -# The name of the connection. -[Parameter(Position=0,Mandatory=$true,ValueFromPipelineByPropertyName=$true)] -[Alias('Name')][string] $ProfileName, -# The name of a server (and optional instance) to connect and use for the query. -[Parameter(Position=1,Mandatory=$true,ValueFromPipelineByPropertyName=$true)] -[Alias('Server','DataSource')][string] $ServerInstance, -# The the database to connect to on the server. -[Parameter(Position=2,Mandatory=$true,ValueFromPipelineByPropertyName=$true)] -[Alias('InitialCatalog')][string] $Database, -<# -The username to connect with. No password will be stored. -If no username is given, a trusted connection will be created. -#> -[Parameter(Position=3,ValueFromPipelineByPropertyName=$true)] -[Alias('UID')][string] $UserName, -# Overwrite an existing profile with the same name. -[switch] $Force -) -Begin -{ - [psobject[]]$connections = Get-VSCodeSetting.ps1 /mssql.connections -Workspace - if(!$connections) {[psobject[]]$connections = @()} -} -Process -{ - if($connections |Where-Object profileName -eq $ProfileName) - { - if($Force) {$connections = $connections |Where-Object profileName -ne $ProfileName} - else {Write-Verbose "Connection '$ProfileName' already exists"; return} - } - $connections += - if($UserName) - {[pscustomobject]@{ - server = $ServerInstance - database = $Database - authenticationType = 'SqlLogin' - profileName = $ProfileName - password = '' - user = $UserName - savePassword = $false - }} - else - {[pscustomobject]@{ - server = $ServerInstance - database = $Database - authenticationType = 'Integrated' - profileName = $ProfileName - password = '' - }} -} -End -{ - $connections |ConvertTo-Json -Compress |Write-Verbose - Set-VSCodeSetting.ps1 /mssql.connections $connections -Workspace -} diff --git a/Copy-GitHubLabels.ps1 b/Copy-GitHubLabels.ps1 deleted file mode 100644 index 7c2484e..0000000 --- a/Copy-GitHubLabels.ps1 +++ /dev/null @@ -1,71 +0,0 @@ -<# -.SYNOPSIS -Copies configured issue labels from one repo to another. - -.FUNCTIONALITY -Git and GitHub - -.INPUTS -An object with these properties: -* owner or DestinationOwnerName (optional) -* name or DestinationRepositoryName - -.LINK -Get-GitHubLabel - -.LINK -New-GitHubLabel - -.LINK -Set-GitHubLabel - -.LINK -Remove-GitHubLabel - -.EXAMPLE -Copy-GitHubLabels.ps1 -OwnerName brianary -RepositoryName scripts -DestinationRepositoryName webcoder - -Inserts new labels from the brianary/scripts repo to the brianary/webcoder repo, and also -updates attributes like description and color from matching labels in the source. -#> - -#Requires -Version 7 -#Requires -Modules PowerShellForGitHub -[CmdletBinding()] Param( -# The source repository's owner name. -[Parameter(Position=0,Mandatory=$true)][string] $OwnerName, -# The source repository name. -[Parameter(Position=1,Mandatory=$true)][string] $RepositoryName, -# The destination repository's owner name. -[Parameter(ValueFromPipelineByPropertyName=$true)][Alias('owner')][string] $DestinationOwnerName = $OwnerName, -# The destination repository name. -[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][Alias('name')][string] $DestinationRepositoryName, -<# -Determines the copy behavior: -* AddNew: Insert new labels from the source. -* AddAndUpdate: Insert new labels from the source, and also overwrite attributes from matching labels in the source. -* ReplaceAll: Insert new labels from the source, overwrite attributes from matching labels in the source, and delete - any labels that don't exist in the source. -#> -[ValidateSet('AddAndUpdate','AddNew','ReplaceAll')][string] $Mode = 'AddAndUpdate' -) -Begin -{ - [pscustomobject[]] $source = Get-GitHubLabel -OwnerName $OwnerName -RepositoryName $RepositoryName -} -Process -{ - $destination = @{ OwnerName = $DestinationOwnerName; RepositoryName = $DestinationRepositoryName } - [pscustomobject[]] $labels = Get-GitHubLabel @destination - $source |Where-Object LabelName -NotIn $labels.LabelName | - ForEach-Object {New-GitHubLabel @destination -Label $_.name -Color $_.color -Description $_.description} - if($Mode -ne 'AddNew') - { - $source |Where-Object LabelName -In $labels.LabelName | - ForEach-Object {Set-GitHubLabel @destination -Label $_.name -Color $_.color -Description $_.description} - if($Mode -eq 'ReplaceAll') - { - $labels |Where-Object LabelName -NotIn $source.LabelName |Remove-GitHubLabel @destination - } - } -} diff --git a/Export-OpenApiSchema.ps1 b/Export-OpenApiSchema.ps1 deleted file mode 100644 index fdf9b6f..0000000 --- a/Export-OpenApiSchema.ps1 +++ /dev/null @@ -1,50 +0,0 @@ -<# -.SYNOPSIS -Extracts a JSON schema from an OpenAPI definition. - -.OUTPUTS -System.String of the extracted JSON schema. - -.FUNCTIONALITY -Json - -.LINK -https://www.openapis.org/ - -.LINK -Export-Json - -.LINK -Set-Json - -.EXAMPLE -Export-OpenApiSchema api.json - -Returns the schema of the 200 response of any defined endpoint is returned. - -.EXAMPLE -Export-OpenApiSchema api.json POST /hello -RequestSchema - -Returns the schema of the request body of the POST /hello endpoint. -#> - -[CmdletBinding(DefaultParameterSetName='ResponseStatus')][OutputType([string])] Param( -# The path to the OpenAPI JSON file. -[Parameter(Position=0)][string] $Path, -# The HTTP verb of the endpoint to extract the schema from. -[Parameter(Position=1)][string] $Method = '*', -# The HTTP path of the endpoint to extract the schema from. -[Parameter(Position=2)][Alias('ApiPath')][string] $EndpointPath = '*', -# Indicates that the request schema of the endpoint should be returned. -[Parameter(ParameterSetName='RequestSchema')][Alias('In')][switch] $RequestSchema, -# Indicates the HTTP status code of the response schema of the endpoint that should be returned. -[Parameter(ParameterSetName='ResponseStatus',Position=3)][int] $ResponseStatus = 200 -) -Process -{ - $Method = $Method.ToLowerInvariant() - return ($PSCmdlet.ParameterSetName -eq 'RequestSchema' ` - ? (Export-Json "/paths/$EndpointPath/$Method/parameters/*/schema" -Path $Path) - : (Export-Json "/paths/$EndpointPath/$Method/responses/$ResponseStatus/content/*/schema" -Path $Path) ) | - Set-Json '/$schema' 'http://json-schema.org/draft-04/schema#' -} diff --git a/Find-DotNetTools.ps1 b/Find-DotNetTools.ps1 deleted file mode 100644 index c52bd53..0000000 --- a/Find-DotNetTools.ps1 +++ /dev/null @@ -1,35 +0,0 @@ -<# -.SYNOPSIS -Returns a list of matching dotnet tools. - -.FUNCTIONALITY -DotNet - -.EXAMPLE -Find-DotNetTools.ps1 interactive |Format-Table -AutoSize - -PackageName Version Authors Downloads Verified ------------ ------- ------- --------- -------- -microsoft.dotnet-interactive 1.0.516401 Microsoft 33682741 True -dotnet-repl 0.1.216 jonsequitur 117599 False -#> - -#Requires -Version 3 -[CmdletBinding()] Param( -# The name of the tool to search for. -[Parameter(Position=0,Mandatory=$true)][string] $Name -) - -Use-Command.ps1 dotnet "$env:ProgramFiles\dotnet\dotnet.exe" -cinst dotnet-sdk - -foreach($line in dotnet tool search $Name |Where-Object {$_ -match '^\S+\s+\d+(?:\.\d+)+\b'}) -{ - $package,$version,$authors,$downloads,$verified = $line -split '\s\s+',5 - [pscustomobject]@{ - PackageName = $package - Version = try{[semver]$version}catch{try{[version]$version}catch{$version}}; - Authors = $authors - Downloads = [long]$downloads - Verified = $verified.Trim() -eq 'x' - } -} diff --git a/Get-AssemblyFramework.ps1 b/Get-AssemblyFramework.ps1 deleted file mode 100644 index d8e120a..0000000 --- a/Get-AssemblyFramework.ps1 +++ /dev/null @@ -1,38 +0,0 @@ -<# -.SYNOPSIS -Gets the framework version an assembly was compiled for. - -.INPUTS -Objects with System.String properties named Path or FullName. - -.OUTPUTS -System.Management.Automation.PSCustomObject with RuntimeVersion and CompileVersion properties. - -.FUNCTIONALITY -DotNet - -.LINK -https://stackoverflow.com/questions/3460982/determine-net-framework-version-for-dll#25649840 - -.EXAMPLE -Get-AssemblyFramework.ps1 Program.exe - -RuntimeVersion CompileVersion --------------- -------------- -v4.0.30319 .NETFramework,Version=v4.7.2 -#> - -[CmdletBinding()][OutputType([Management.Automation.PSCustomObject])] Param( -# The assembly to get the framework version of. -[Parameter(Position=0,Mandatory=$true,ValueFromPipelineByPropertyName=$true)][Alias('FullName')][string] $Path -) -Process -{ - $assembly = [Reflection.Assembly]::ReflectionOnlyLoadFrom((Resolve-Path $Path)) - [PSCustomObject]@{ - RuntimeVersion = $assembly.ImageRuntimeVersion - CompileVersion = $assembly.CustomAttributes | - Where-Object {$_.AttributeType.Name -eq "TargetFrameworkAttribute" } | - ForEach-Object {$_.ConstructorArguments.value} - } -} diff --git a/Get-GitFileMetadata.ps1 b/Get-GitFileMetadata.ps1 deleted file mode 100644 index 75a3735..0000000 --- a/Get-GitFileMetadata.ps1 +++ /dev/null @@ -1,60 +0,0 @@ -<# -.SYNOPSIS -Returns the creation and last modification metadata for a file in a git repo. - -.FUNCTIONALITY -Git and GitHub - -.LINK -Use-Command.ps1 - -.LINK -Get-ChildItem - -.LINK -Resolve-Path - -.EXAMPLE -Get-GitFileMetadata.ps1 README.md - -Path : .\README.md -CreateCommit : 1fde7af -CreateAuthor : Brian Lalonde -CreateEmail : brianary@example.com -CreateDate : 01/19/2015 11:44:15 -LastCommit : dbe27ba -LastAuthor : Brian Lalonde -LastEmail : brianary@example.com -LastDate : 12/07/2020 20:17:15 -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([psobject])] Param( -# The path (or paths) to get metadata for. -[Parameter(Position=0,Mandatory=$true,ValueFromPipelineByPropertyName=$true,ValueFromRemainingArguments=$true)] -[string[]] $Path, -# Recurse into subdirectories. -[switch] $Recurse -) -Begin { Use-Command.ps1 git "$env:ProgramFiles\Git\cmd\git.exe" -choco git } -Process -{ - foreach($f in Get-ChildItem $Path -Recurse:$Recurse) - { - $create_commit,$create_author,$create_email,$create_date = - (git log --reverse --format="%h%x09%cn%x09%ae%x09%ai" $f |Select-Object -f 1) -split '\t' - $last_commit,$last_author,$last_email,$last_date = - (git log -1 --format="%h%x09%cn%x09%ae%x09%ai" $f |Select-Object -f 1) -split '\t' - [pscustomobject]@{ - Path = Resolve-Path $f -Relative - CreateCommit = $create_commit - CreateAuthor = $create_author - CreateEmail = $create_email - CreateDate = [datetime]$create_date - LastCommit = $last_commit - LastAuthor = $last_author - LastEmail = $last_email - LastDate = [datetime]$last_date - } - } -} diff --git a/Get-GitFirstCommit.ps1 b/Get-GitFirstCommit.ps1 deleted file mode 100644 index e4a6ef4..0000000 --- a/Get-GitFirstCommit.ps1 +++ /dev/null @@ -1,23 +0,0 @@ -<# -.SYNOPSIS -Gets the SHA-1 hash of the first commit of the current repo. - -.OUTPUTS -System.String containing the SHA-1 hash of this repo's first commit. - -.FUNCTIONALITY -Git and GitHub - -.LINK -Use-Command.ps1 - -.EXAMPLE -Get-GitFirstCommit.ps1 - -1fde7af20e8560c720d42227495e8d15459aafa4 -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([string])] Param() -Use-Command.ps1 git "$env:ProgramFiles\Git\cmd\git.exe" -choco git -git log --max-parents=0 --format=format:%H HEAD diff --git a/Get-GitHubRepoChildItem.ps1 b/Get-GitHubRepoChildItem.ps1 deleted file mode 100644 index fd5358f..0000000 --- a/Get-GitHubRepoChildItem.ps1 +++ /dev/null @@ -1,131 +0,0 @@ -<# -.SYNOPSIS -Gets the items and child items in one or more specified locations. - -.EXAMPLE -Get-GitHubRepoChildItem.ps1 -Filter *.csproj -Recurse -File -OwnerName PowerShell -RepositoryName PSScriptAnalyzer |Format-Table name,size,path -AutoSize - -name size path ----- ---- ---- -Engine.csproj 3679 Engine/Engine.csproj -Rules.csproj 2586 Rules/Rules.csproj - -.EXAMPLE -Get-GitHubRepoChildItem.ps1 -Path src -AlternatePath / -Filter LICENSE -File -OwnerName PowerShell -RepositoryName PSScriptAnalyzer - -name : LICENSE -path : LICENSE -sha : cec380d8ef7f7a1ad3ff9ef2356a88a13a78b491 -size : 1089 -url : https://api.github.com/repos/PowerShell/PSScriptAnalyzer/contents/LICENSE?ref=master -html_url : https://github.com/PowerShell/PSScriptAnalyzer/blob/master/LICENSE -git_url : https://api.github.com/repos/PowerShell/PSScriptAnalyzer/git/blobs/cec380d8ef7f7a1ad3ff9ef2356a88a13a78b491 -download_url : https://raw.githubusercontent.com/PowerShell/PSScriptAnalyzer/master/LICENSE -type : file -_links : @{self=https://api.github.com/repos/PowerShell/PSScriptAnalyzer/contents/LICENSE?ref=master; git=https://api.github.com/repos/PowerShell/PSScriptAnalyzer/git/blobs/cec380d8ef7f7a1ad3ff9ef2356a88a13a78b491; html=https://github.com/PowerShell/PSScriptAnalyzer/blob/master/LICENSE} -#> - -#Requires -Version 7 -#Requires -Modules PowerShellForGitHub -[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars','', -Justification='Using a global variable to cache responses, to avoid abusive API iteration.')] -[CmdletBinding()] Param( -# The path for which to retrieve contents. -[Parameter(Position=0)][string] $Path = '', -# Specifies a wildcard pattern to filter matches against. -[string] $Filter = '*', -# Specifies a wildcard pattern to exclude matches against. -[string] $Exclude = '', -# An alternate path to retrieve if the primary Path isn't found. -[string] $AlternatePath, -# Indicates subdirectories should be searched. -[switch] $Recurse, -# Indicates that only files should be returned. -[switch] $File, -# Indicates that only directories should be returned. -[switch] $Directory, -# Owner of the repository. -[Parameter(ValueFromPipelineByPropertyName)][psobject] $OwnerName, -# Name of the repository. -[Parameter(ValueFromPipelineByPropertyName)][Alias('Name')][string] $RepositoryName, -# The branch, or defaults to the default branch of not specified. -[string] $BranchName, -# Ignores any cached result and re-queries the GitHub API. -[switch] $Force -) -Begin -{ - if(!(Get-Variable GitHubRepoContents -Scope Global -ErrorAction SilentlyContinue)) {$Global:GitHubRepoContents = @{}} - function Get-PathContentOrAlternate - { - [CmdletBinding()] Param( - [psobject] $OwnerName, - [string] $RepositoryName, - [string] $Path, - [string] $Branch, - [string] $AlternatePath - ) - [void]$PSBoundParameters.Remove('AlternatePath') - if($Path -in '','.','/') {[void]$PSBoundParameters.Remove('Path')} - try {return Get-GitHubContent @PSBoundParameters} - catch [Microsoft.PowerShell.Commands.HttpResponseException] - { - Write-Verbose "Could not find path $Path in $OwnerName/$RepositoryName" - if($_.Exception.Response.StatusCode -ne 404 -or $AlternatePath -eq $null) {throw} - if($AlternatePath -in '','.','/') {[void]$PSBoundParameters.Remove('Path')} - else {$PSBoundParameters['Path'] = $AlternatePath} - return Get-GitHubContent @PSBoundParameters - } - } -} -Process -{ - Write-Verbose $MyInvocation.Line - if($OwnerName -isnot [string]) {$PSBoundParameters['OwnerName'] = $OwnerName = $OwnerName.UserName} - $repoContext, $searchContext = "$OwnerName/$RepositoryName/$BranchName", - "$Path|$AlternatePath|$Filter|$Exclude|$Recurse|$File|$Directory" - if(!$Global:GitHubRepoContents.ContainsKey($repoContext)) - { - $Global:GitHubRepoContents[$repoContext] = @{} - } - elseif(!$Force -and $Global:GitHubRepoContents[$repoContext].ContainsKey($searchContext)) - { - return $Global:GitHubRepoContents[$repoContext][$searchContext] - } - $entryType = if($File -and $Directory) {''} elseif($File) {'file'} elseif($Directory) {'dir'} else {'*'} - $contentSpec = @{ - OwnerName = $OwnerName - RepositoryName = $RepositoryName - Path = $Path - AlternatePath = $AlternatePath - } - if($BranchName) {$contentSpec += @{BranchName=$BranchName}} - Write-Progress "Searching $OwnerName/$RepositoryName $BranchName" ( $Path ? $Path : '/' ) - if(!$Force -and $Global:GitHubRepoContents[$repoContext].ContainsKey("$Path|$AlternatePath")) - { - $content = $Global:GitHubRepoContents[$repoContext]["$Path|$AlternatePath"] - } - else - { - $content = Get-PathContentOrAlternate @contentSpec - $Global:GitHubRepoContents[$repoContext]["$Path|$AlternatePath"] = $content - } - if($content.type -eq 'file') - { - if($content.type -notlike $entryType -or $content.name -notlike $Filter -or $content.name -like $Exclude) {return} - $Global:GitHubRepoContents[$repoContext][$searchContext] = $content - return $content - } - $found = @($content.entries | - Where-Object {$_.type -like $entryType -and $_.name -like $Filter -and $_.name -notlike $Exclude}) - if($Recurse) - { - $found += @($content.entries | - Where-Object {$_.type -eq 'dir' -and $_.name -notlike $Exclude} | - ForEach-Object {& $PSCommandPath -Path $_.path -Filter $Filter -Exclude $Exclude -Recurse -File:$File ` - -Directory:$Directory -OwnerName $OwnerName -RepositoryName $RepositoryName -BranchName $BranchName}) - } - $Global:GitHubRepoContents[$repoContext][$searchContext] = $found - Write-Progress "Searching $OwnerName/$RepositoryName $BranchName" -Completed - return $found -} diff --git a/Get-LibraryVulnerabilityInfo.ps1 b/Get-LibraryVulnerabilityInfo.ps1 deleted file mode 100644 index 3393b85..0000000 --- a/Get-LibraryVulnerabilityInfo.ps1 +++ /dev/null @@ -1,60 +0,0 @@ -<# -.SYNOPSIS -Get the list of module/package/library vulnerabilities from the RetireJS or SafeNuGet projects. - -.INPUTS -System.String of a package/module name to search for. - -.OUTPUTS -System.Management.Automation.PSCustomObject with details about any vulnerabilities found. - -.FUNCTIONALITY -Packages and libraries - -.LINK -Invoke-RestMethod - -.LINK -Select-Xml - -.EXAMPLE -Get-LibraryVulnerabilityInfo.ps1 Backbone.js - -atOrAbove below identifiers info ---------- ----- ----------- ---- - 0.5.0 @{release=0.5.0; summary=cross-site scripting vulnerability} {http://backbonejs.org/#changelog} - - -.EXAMPLE -Get-LibraryVulnerabilityInfo.ps1 Backbone.js -Repository nuget - -id before infoUri --- ------ ------- -Backbone.js 0.5.3 http://backbonejs.org/#changelog -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([Management.Automation.PSCustomObject])] Param( -# The name of the module or package or library to check. -[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)] -[Alias('Module','Package','Library')][string]$Name, -# Whether to check the NPM, JS, or NuGet vulnerability lists. -[ValidateSet('js','npm','nuget')][string]$Repository = 'js' -) -Process -{ - if($Repository -eq 'nuget') - { - Invoke-RestMethod https://raw.githubusercontent.com/OWASP/SafeNuGet/master/feed/unsafepackages.xml | - Select-Xml //package | - Select-Object -ExpandProperty Node | - Where-Object {$_.id -eq $Name} | - ForEach-Object {[pscustomobject]@{id=$_.id;before=$_.before;infoUri=$_.infoUri}} - } - else - { - $lib = Invoke-RestMethod https://raw.githubusercontent.com/RetireJS/retire.js/master/repository/${Repository}repository.json - if($lib.$Name) {$lib.$Name.vulnerabilities |Select-Object atOrAbove,below,identifiers,info} - else {Write-Warning "$Name not found"} - } -} diff --git a/Get-NuGetConfigs.ps1 b/Get-NuGetConfigs.ps1 deleted file mode 100644 index 1770ec2..0000000 --- a/Get-NuGetConfigs.ps1 +++ /dev/null @@ -1,38 +0,0 @@ -<# -.SYNOPSIS -Returns the available NuGet configuration files, in order of preference. - -.OUTPUTS -System.String containing the path to a NuGet config file. - -.FUNCTIONALITY -Configuration - -.LINK -https://docs.myget.org/docs/how-to/nuget-configuration-inheritance - -.EXAMPLE -Get-NuGetConfigs.ps1 - -C:\Users\zaphodb\GitHub\ProjectX\src\nuget.config -C:\Users\zaphodb\AppData\Roaming\NuGet\NuGet.config -C:\ProgramData\NuGet\Config.config -C:\ProgramData\NuGet\NuGetDefaults.config -#> - -#Requires -Version 7 -[CmdletBinding()][OutputType([string])] Param( -# The directory to walk the parents of, to look for configs. -[Parameter(Position=0)][string] $Directory = "$PWD" -) - -function Get-Parent([Parameter(Position=0)][string] $Directory) -{ - if($Directory -eq "$(Join-Path (Split-Path $Directory -Qualifier) '')") {$Directory} - else {$Directory; Get-Parent (Split-Path $Directory)} -} - -Get-Parent $Directory |ForEach-Object {Join-Path $_ nuget.config} |Where-Object {Test-Path $_ -Type Leaf} -Join-Path $env:APPDATA NuGet NuGet.config |Where-Object {Test-Path $_ -Type Leaf} -Join-Path $env:ProgramData NuGet Config*.config |Resolve-Path -ErrorAction Ignore |Sort-Object Length -Descending -Join-Path $env:ProgramData NuGet NuGetDefaults.config |Where-Object {Test-Path $_ -Type Leaf} diff --git a/Get-OpenApiInfo.ps1 b/Get-OpenApiInfo.ps1 deleted file mode 100644 index 65e7a5b..0000000 --- a/Get-OpenApiInfo.ps1 +++ /dev/null @@ -1,50 +0,0 @@ -<# -.SYNOPSIS -Returns metadata from an OpenAPI definition. - -.FUNCTIONALITY -Json - -.LINK -https://www.openapis.org/ - -.EXAMPLE -Get-OpenApiInfo.ps1 .\test\data\sample-openapi.json - -Source : .\test\data\sample-openapi.json -OpenApi : 3.0.3 -Title : Sample REST API -Description : An example OpenAPI definition. -Version : 1.0.0 -Endpoints : {@{Endpoint=GET /users/{userId}; Summary=Returns a user by ID.; Description=Gets a user's details.}, -| @{Endpoint=POST /users; Summary=Creates a new user.; Description=Adds a user account.}} -#> - -#Requires -Version 7 -[CmdletBinding()] Param( -[Parameter(Position=0,Mandatory=$true,ValueFromPipelineByPropertyName=$true)][Alias('FullName')][string] $Path -) -Process -{ - Get-Content $Path -Raw | - ConvertFrom-Json -AsHashtable | - ForEach-Object {[pscustomobject]@{ - Source = $Path - OpenApi = $_.ContainsKey('openapi') ? $_.openapi : - $_.ContainsKey('swagger') ? $_.swagger : $null - Title = $_.info.title - Description = $_.info.description - Version = $_.info.version - Endpoints = $_.paths.GetEnumerator() |% { - $p = $_.Key - $e = $_.Value - $_.Value.Keys |% { - [pscustomobject]@{ - Endpoint = "$($_.ToUpperInvariant()) $p" - Summary = $e[$_].summary - Description = $e[$_].description - } - } - } - }} -} \ No newline at end of file diff --git a/Get-RepoName.ps1 b/Get-RepoName.ps1 deleted file mode 100644 index 48b71f7..0000000 --- a/Get-RepoName.ps1 +++ /dev/null @@ -1,37 +0,0 @@ -<# -.SYNOPSIS -Gets the name of the repo. - -.INPUTS -Objects with System.String Path or FullName properties. - -.OUTPUTS -System.String of the repo name (the final segment of the first remote location). - -.FUNCTIONALITY -Git and GitHub - -.EXAMPLE -Get-RepoName.ps1 -#> - -[CmdletBinding()][OutputType([string])] Param( -# The path to the git repo to get the name for. -[Parameter(Position=0,ValueFromPipelineByPropertyName=$true)] -[Alias('FullName')][string] $Path = $PWD.Path -) -Begin { Use-Command.ps1 git "$env:ProgramFiles\Git\cmd\git.exe" -cinst git } -Process -{ - if(!(Test-Path $Path -Type Container)) {ModernConveniences\Stop-ThrowError "The path $Path was not found." -Argument Path} - try - { - Push-Location $Path - git status |Out-Null - if(!$?) {ModernConveniences\Stop-ThrowError "The path $Path is not a git repo."-Argument Path} - $remote = git remote |Select-Object -First 1 - if($remote) {return ([uri](git remote get-url $remote)).Segments[-1] -replace '\.git\z',''} - else {return Split-Path $Path -Leaf} - } - finally {Pop-Location} -} diff --git a/Get-Todos.ps1 b/Get-Todos.ps1 deleted file mode 100644 index 731e076..0000000 --- a/Get-Todos.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -<# -.SYNOPSIS -Returns the TODOs for the current git repo, which can help document technical debt. - -.EXAMPLE -Get-Todos.ps1 |Out-GridView -Title "$((Get-Item $(git rev-parse --show-toplevel)).Name) TODOs" - -Shows TODOs in this repo. -#> - -#Requires -Version 7 -[CmdletBinding()] Param() - -Push-Location $(git rev-parse --show-toplevel) -Find-Lines.ps1 -Pattern '\bTODO\b' -Filters * -Path ((Test-Path src -Type Container) ? 'src' : '.') -CaseSensitive | - ForEach-Object { - [string[]] $blame = git blame -p -L "$($_.LineNumber),$($_.LineNumber)" -- $_.Path - $author = $blame |Select-String '^author (?.*)$' |ModernConveniences\Select-CapturesFromMatches -ValuesOnly - $Time = $blame |Select-String '^author-time (?