Skip to content

Commit

Permalink
Prepare for release v0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhaopudark committed Sep 11, 2023
1 parent eae7a1a commit fc2f448
Show file tree
Hide file tree
Showing 16 changed files with 225 additions and 240 deletions.
73 changes: 0 additions & 73 deletions Module/Config.ps1

This file was deleted.

14 changes: 6 additions & 8 deletions Module/PSComputerManagementZp.psm1
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
. "${PSScriptRoot}\Config.ps1"
. "${PSScriptRoot}\Register.PrivateComponents.ps1"

foreach ($script in $ModuleInfo.ScriptsToExport) {
. $script.FullName
}
Get-Item "${PSScriptRoot}\Public\*.ps1" | ForEach-Object { . $_.FullName }

# Avoid to export all components in the module by `Import-Module *.psm1`
# There's no contradiction with *.psd1.
Export-ModuleMember `
-Function $ModuleInfo.FunctionsToExport `
-Cmdlet $ModuleInfo.CmdletsToExport `
-Variable $ModuleInfo.VariablesToExport `
-Alias $ModuleInfo.AliasesToExport
-Function $local:ModuleInfo.FunctionsToExport `
-Cmdlet $local:ModuleInfo.CmdletsToExport `
-Variable $local:ModuleInfo.VariablesToExport `
-Alias $local:ModuleInfo.AliasesToExport
Original file line number Diff line number Diff line change
Expand Up @@ -131,66 +131,39 @@ function Format-Doc2Markdown{
return $function_comment
}

function Get-PreReleaseString{
<#
.DESCRIPTION
Get the pre-release string from a release note file.
.INPUTS
A release note file path.
.OUTPUTS
A string of the pre-release string.
#>
[OutputType([string])]
param(
[Parameter(Mandatory)]
[string]$ReleaseNotesPath
)
$release_title = Get-Content $ReleaseNotesPath | Select-String -Pattern "^## " | Select-Object -First 1
if ($release_title -match 'v([\d]+\.[\d]+\.[\d]+)[\-]*(.*)'){
$pre_release_string = $Matches[2]
if ($pre_release_string -match 'beta[\d+]|stable'){
$result = $pre_release_string.ToLower()
if ($result -eq 'stable'){
return '' # stable version should not have pre-release string
}
else{
return $result
}
}
else{
throw "[Invalid pre-release string] The pre-release string in $ReleaseNotesPath is $pre_release_string, but it should one be 'stable' or 'beta0', 'beta1' etc."
}
}else{
return ''
}
}

function Assert-ReleaseVersionConsistency{
function Get-SortedNameWithDocFromScript{
<#
.DESCRIPTION
Assert if the release version in the release note file is consistent with the given version.
.PARAMETER Version
The version.
.PARAMETER ReleaseNotesPath
The release note file path.
Get sorted function names with docs from a script file or script files.
.INPUTS
A script file path or script files path, and the type of docs.
.PARAMETER Path
The path of a script file or script files.
.PARAMETER DocType
The type of docs, 'Function' or 'Class'.
.OUTPUTS
None.
A hashtable enumerator with sorted function names as keys(names) and function docs as values.
#>
param(
[Parameter(Mandatory)]
[string]$Version,
[string]$Path,
[Parameter(Mandatory)]
[string]$ReleaseNotesPath
)
[ValidateSet('Function','Class')]
[string]$DocType

$release_title = Get-Content $ReleaseNotesPath | Select-String -Pattern "^# " | Select-Object -First 1
if ($release_title -match 'v([\d]+\.[\d]+\.[\d]+)'){
$release_version = $Matches[1]
if (!($release_version -ceq $Version)){
throw "[Imcompatible version] The newest version in $ReleaseNotesPath is $release_version, but it should be $Version."
)
$source = Get-Item -Path $Path -Include '*.ps1','*.psm1'| ForEach-Object { $_.FullName }
$name_with_docs = @{}
foreach ($item in $source) {
if ($DocType -eq 'Function'){
$name_with_docs += Get-FunctionDoc -Path $item
}else{
$name_with_docs += Get-ClassDoc -Path $item
}
}else{
throw "[Invalid release title] The release title in $ReleaseNotesPath is $release_title, but it should be like '# xxx v0.0.1'."
}
}

$sorted_name_with_docs = $name_with_docs.GetEnumerator() | Sort-Object -Property Name
return $sorted_name_with_docs
}


6 changes: 6 additions & 0 deletions Module/Private/BasicTools.Logger.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ function Get-LogFileName{
<#
.DESCRIPTION
Get the log file name.
.PARAMETER KeyInfo
A string to indicate the key info of the log file.
.INPUTS
A string to indicate the key info of the log file.
.OUTPUTS
Expand All @@ -34,6 +36,8 @@ function Write-FileLog{
<#
.DESCRIPTION
Write log to a file.
.PARAMETER Message
The message to be logged.
.INPUTS
A string to indicate the log message.
.OUTPUTS
Expand Down Expand Up @@ -66,6 +70,8 @@ function Write-Log{
The message to be logged.
.PARAMETER ShowVerbose
Whether to show the message in verbose mode.
.INPUTS
A string and a switch.
.OUTPUTS
None.
#>
Expand Down
2 changes: 0 additions & 2 deletions Module/Private/BasicTools.Platform.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ function Test-Platform{
.OUTPUTS
`$true` if compatible, otherwise `$false`.
.EXAMPLE
```powershell
Test-Platform -Name 'Windows' -Verbose
Test-Platform -Name 'Wsl2' -Verbose
Test-Platform -Name 'Linux' -Verbose
Test-Platform -Name 'MacOS' -Verbose
```
.LINK
Refer to the [doc](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.3&viewFallbackFrom=powershell-6#islinux) for `$IsWindows` and `$IsLinux`.
#>
Expand Down
62 changes: 62 additions & 0 deletions Module/Private/BasicTools.Version.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
function Get-PreReleaseString{
<#
.DESCRIPTION
Get the pre-release string from a release note file.
.INPUTS
A release note file path.
.OUTPUTS
A string of the pre-release string.
#>
[OutputType([string])]
param(
[Parameter(Mandatory)]
[string]$ReleaseNotesPath
)
$release_title = Get-Content $ReleaseNotesPath | Select-String -Pattern "^## " | Select-Object -First 1
if ($release_title -match 'v([\d]+\.[\d]+\.[\d]+)[\-]*(.*)'){
$pre_release_string = $Matches[2]
if ($pre_release_string -match 'beta[\d+]|stable'){
$result = $pre_release_string.ToLower()
if ($result -eq 'stable'){
return '' # stable version should not have pre-release string
}
else{
return $result
}
}
else{
throw "[Invalid pre-release string] The pre-release string in $ReleaseNotesPath is $pre_release_string, but it should one be 'stable' or 'beta0', 'beta1' etc."
}
}else{
return ''
}
}

function Assert-ReleaseVersionConsistency{
<#
.DESCRIPTION
Assert if the release version in the release note file is consistent with the given version.
.PARAMETER Version
The version.
.PARAMETER ReleaseNotesPath
The release note file path.
.OUTPUTS
None.
#>
param(
[Parameter(Mandatory)]
[string]$Version,
[Parameter(Mandatory)]
[string]$ReleaseNotesPath
)

$release_title = Get-Content $ReleaseNotesPath | Select-String -Pattern "^# " | Select-Object -First 1
if ($release_title -match 'v([\d]+\.[\d]+\.[\d]+)'){
$release_version = $Matches[1]
if (!($release_version -ceq $Version)){
throw "[Imcompatible version] The newest version in $ReleaseNotesPath is $release_version, but it should be $Version."
}
}else{
throw "[Invalid release title] The release title in $ReleaseNotesPath is $release_title, but it should be like '# xxx v0.0.1'."
}
}
Loading

0 comments on commit fc2f448

Please sign in to comment.