docs.PsCraft
This PowerShell module is a toolbox to streamline the process of building and distributing PowerShell modules.
To focus on writing code and not get bogged down in intricacies of the build process.
This module aims to eliminate the need to write and test build scripts The only code you are expected to write is in Public functions and Tests.
😔 Tests have to be written by humans. There's just no other way.
The goal is to give you a starting point that just works.
All you need to do is run 3 commands minimum, then let an LLM take care of the rest.
First make sure you install and Import the module.
Import-Module PsCraft
Create a module:
New-PsModule -Name MyModule
The structure used by this module is based on official documentation.
Practical Module Development concepts like separating functionality into directories, along with modular imports, are practical tips shared in blog posts and forums and various developer blogs.
- Sign your scripts
Add-Signature -File MyNewScript.ps1
- Create GUIs
Yes you can create a GUI dor your scripts even on Linux using PowerShell.
Add-GUI -Script MyNewScript.ps1
todo: fix Unresolved bugs:
- remove any invisible characters from repo.
Example: removing any invisible Chars
function Remove-InvisibleChars {
<#
.SYNOPSIS
Removes invisible characters from all files in the current directory and subdirectories.
.NOTES
- Written by chatgpt for Linux.
- Requires `sed` or appropriate substitution tool.
#>
[CmdletBinding()]
param (
[string[]]$chars = @(
"`x00", # Null
"`x01", # Start of Header
"`x02", # Start of Text
"`x03", # End of Text
"`x09", # Horizontal Tab
"`x0B", # Vertical Tab
"`x0C" # Form Feed
)
)
# Retrieve all files recursively
$files = Get-ChildItem -File -Recurse -Force
foreach ($file in $files) {
Write-Verbose "Processing file: $($file.FullName)"
# Read content of the file
$content = Get-Content -Raw -Path $file.FullName
# Remove invisible characters
foreach ($char in $chars) {
$charValue = [char][byte]($char -replace '`x', '0x')
$content = $content -replace [regex]::Escape($charValue), ''
}
# Save the cleaned content back to the file
$cleanFilePath = [System.IO.Path]::Combine($file.DirectoryName, "$($file.BaseName)_clean$($file.Extension)")
Set-Content -Path $cleanFilePath -Value $content
}
# Optionally delete old files and rename cleaned files
foreach ($file in $files) {
$cleanFilePath = [System.IO.Path]::Combine($file.DirectoryName, "$($file.BaseName)_clean$($file.Extension)")
if (Test-Path $cleanFilePath) {
Remove-Item -Path $file.FullName -Verbose
Rename-Item -Path $cleanFilePath -NewName $file.Name -Verbose
}
}
}