Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .assets/config/bash_cfg/aliases_git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ function git_current_branch {
function git_resolve_branch {
case "$1" in
'')
pattern='(^|/)dev(|el|elop|elopment)$|(^|/)ma(in|ster)$|(^|/)trunk$'
# `(el|elop|elopment)?` instead of the empty-alternative `(|el|elop|elopment)`
# which BSD grep on macOS silently fails to match (returns the literal regex
# instead of resolving to dev/devel/development).
pattern='(^|/)dev(el|elop|elopment)?$|(^|/)ma(in|ster)$|(^|/)trunk$'
;;
d)
pattern='(^|/)dev(|el|elop|elopment)$'
pattern='(^|/)dev(el|elop|elopment)?$'
;;
m)
pattern='(^|/)ma(in|ster)$'
Expand Down Expand Up @@ -56,7 +59,7 @@ alias gb='git branch'
alias gba='git branch -a'
alias gbd='git branch -d'
alias gbd!='git branch -D'
alias gbda='git branch --format="%(refname:short)" --merged | command grep -vE "^ma(in|ster)$|^dev(|el|elop)$|^qa$|^stage$|^trunk$" | command xargs -n 1 git branch -d'
alias gbda='git branch --format="%(refname:short)" --merged | command grep -vE "^ma(in|ster)$|^dev(el|elop)?$|^qa$|^stage$|^trunk$" | command xargs -n 1 git branch -d'
alias gbnm='git branch --no-merged'
alias gbr='git branch --remote'
alias gbsu='git branch --set-upstream-to=origin/$(git_current_branch)'
Expand Down
6 changes: 3 additions & 3 deletions .assets/provision/install_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ fedora)
rpm -q patch >/dev/null 2>&1 || dnf group install -y development-tools 2>/dev/null || true
# install base packages
if [ "$(readlink "$(which dnf)")" = 'dnf5' ]; then
pkgs="bash-completion bind-utils curl dnf5-plugins fd gawk git iputils jq man-db nmap shfmt openssl tar tig tree unzip vim wget which whois"
pkgs="bash-completion bind-utils curl dnf5-plugins fd-find gawk git iputils jq man-db nmap shfmt openssl tar tig tree unzip vim wget which whois"
else
pkgs="bash-completion bind-utils curl dnf-plugins-core fd gawk git iputils jq man-db nmap shfmt openssl tar tig tree unzip vim wget which whois"
pkgs="bash-completion bind-utils curl dnf-plugins-core fd-find gawk git iputils jq man-db nmap shfmt openssl tar tig tree unzip vim wget which whois"
fi
install_pkgs dnf "$pkgs"
;;
Expand All @@ -108,7 +108,7 @@ debian | ubuntu)
# refresh package index
apt-get update 2>/dev/null
# install base packages
pkgs="build-essential bash-completion ca-certificates curl fd gawk gnupg dnsutils git iputils-tracepath jq lsb-release man-db nmap shfmt openssl tar tig tree unzip vim wget which whois"
pkgs="build-essential bash-completion ca-certificates curl fd-find gawk gnupg dnsutils git iputils-tracepath jq lsb-release man-db nmap shfmt openssl tar tig tree unzip vim wget which whois"
install_pkgs apt "$pkgs"
# autoremove unnecessary packages and clean up apt cache
apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
Expand Down
39 changes: 17 additions & 22 deletions .assets/scripts/linux_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -253,29 +253,24 @@ printf "\e[96msetting up profile for current user...\e[0m\n"
.assets/provision/setup_profile_user.sh
# install powershell modules
if [ -f /usr/bin/pwsh ]; then
cmnd="Import-Module (Resolve-Path './modules/InstallUtils'); Invoke-GhRepoClone -OrgRepo 'szymonos/ps-modules' -WarningAction SilentlyContinue"
cloned=$(pwsh -nop -c "$cmnd")
if [ $cloned -gt 0 ]; then
printf "\e[96minstalling ps-modules...\e[0m\n"
# install do-common module for all users
printf "\e[3;32mAllUsers\e[23m : do-common\e[0m\n"
sudo ../ps-modules/module_manage.ps1 'do-common' -CleanUp
printf "\e[96minstalling ps-modules...\e[0m\n"
# install do-common module for all users
printf "\e[3;32mAllUsers\e[23m : do-common\e[0m\n"
sudo mkdir -p /usr/local/share/powershell/Modules
sudo rm -rf /usr/local/share/powershell/Modules/do-common
sudo cp -rf modules/do-common /usr/local/share/powershell/Modules/

# determine current user scope modules to install
modules=('do-linux')
grep -qw 'az' <<<$scope && modules+=(do-az) || true
[ -f /usr/bin/git ] && modules+=(aliases-git) || true
[ -f /usr/bin/kubectl ] && modules+=(aliases-kubectl) || true
# Convert the modules array to a comma-separated string with quoted elements
printf "\e[3;32mCurrentUser\e[23m : ${modules[*]}\e[0m\n"
mods=''
for element in "${modules[@]}"; do
mods="$mods'$element',"
done
pwsh -nop -c "@(${mods%,}) | ../ps-modules/module_manage.ps1 -CleanUp"
else
printf '\e[33mps-modules repository cloning failed\e[0m.\n'
fi
# determine current user scope modules to install
modules=('do-linux')
grep -qw 'az' <<<$scope && modules+=(do-az) || true
[ -f /usr/bin/git ] && modules+=(aliases-git) || true
[ -f /usr/bin/kubectl ] && modules+=(aliases-kubectl) || true
printf "\e[3;32mCurrentUser\e[23m : ${modules[*]}\e[0m\n"
mkdir -p "$HOME/.local/share/powershell/Modules"
for module in "${modules[@]}"; do
rm -rf "$HOME/.local/share/powershell/Modules/$module"
cp -rf "modules/$module" "$HOME/.local/share/powershell/Modules/"
done
fi

# restore working directory
Expand Down
75 changes: 20 additions & 55 deletions .assets/scripts/modules_update.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/pwsh -nop
#!/usr/bin/env pwsh
#Requires -PSEdition Core -Version 7.3
<#
.SYNOPSIS
Expand All @@ -13,11 +13,11 @@ Check if repository is up to date and reset to origin if necessary.

.NOTES
# :save script example
./scripts_egsave.ps1 .assets/scripts/modules_update.ps1
.assets/scripts/scripts_egsave.ps1 .assets/scripts/modules_update.ps1
# :override the existing script example if exists
./scripts_egsave.ps1 .assets/scripts/modules_update.ps1 -Force
.assets/scripts/scripts_egsave.ps1 .assets/scripts/modules_update.ps1 -Force
# :open the example script in VSCode
code -r (./scripts_egsave.ps1 .assets/scripts/modules_update.ps1 -WriteOutput)
code -r (.assets/scripts/scripts_egsave.ps1 .assets/scripts/modules_update.ps1 -WriteOutput)
#>
[CmdletBinding()]
param (
Expand All @@ -41,38 +41,8 @@ begin {

# set location to workspace folder
Push-Location "$PSScriptRoot/../.."
# import InstallUtils for the Invoke-GhRepoClone function
Import-Module (Resolve-Path './modules/InstallUtils')

# specify update functions structure
$import = @{
'do-common' = @{
SetupUtils = @{
certs = @(
'ConvertFrom-PEM'
'ConvertTo-PEM'
'Get-Certificate'
)
common = @(
'Get-LogMessage'
'ConvertFrom-Cfg'
'ConvertTo-Cfg'
'Get-ArrayIndexMenu'
'Invoke-ExampleScriptSave'
)
}
}
'psm-windows' = @{
InstallUtils = @{
common = @(
'Invoke-CommandRetry'
'Join-Str'
'Test-IsAdmin'
'Update-SessionEnvironmentPath'
)
}
}
}
# import utils-install for the Invoke-GhRepoClone function
Import-Module (Resolve-Path './modules/utils-install')
}

process {
Expand All @@ -84,25 +54,20 @@ process {

# *perform update
Write-Host 'perform modules update..' -ForegroundColor Cyan
foreach ($srcModule in $import.GetEnumerator()) {
Import-Module (Resolve-Path "../ps-modules/modules/$($srcModule.Key)")
Write-Host "`n$($srcModule.Key)" -ForegroundColor Green
foreach ($dstModule in $srcModule.Value.GetEnumerator()) {
Write-Host $dstModule.Key
foreach ($destFile in $dstModule.Value.GetEnumerator()) {
Write-Host " - $($destFile.Key).ps1"
$filePath = "./modules/$($dstModule.Key)/Functions/$($destFile.Key).ps1"
Set-Content -Value $null -Path $filePath
$builder = [System.Text.StringBuilder]::new()
foreach ($function in $destFile.Value) {
Write-Host " • $function"
$def = " $((Get-Command $function -CommandType Function).Definition.Trim())"
$builder.AppendLine("function $function {") | Out-Null
$builder.AppendLine($def) | Out-Null
$builder.AppendLine("}`n") | Out-Null
}
Set-Content -Value $builder.ToString().Trim().Replace("`r`n", "`n") -Path $filePath -Encoding utf8
}
$modules = @(
'aliases-git'
'aliases-kubectl'
'do-az'
'do-common'
'do-linux'
'psm-windows'
)
foreach ($module in $modules) {
try {
Remove-Item -Path "./modules/$module" -Recurse -Force -ErrorAction SilentlyContinue
Copy-Item -Path "../ps-modules/modules/$module" -Destination "./modules" -Recurse
} catch {
Write-Warning "Failed to update module ${module}: $_"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions .assets/scripts/vg_cacert_fix.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ begin {
# set location to workspace folder
Push-Location "$PSScriptRoot/../.."

# import SetupUtils for the Set-WslConf function
Import-Module (Convert-Path './modules/SetupUtils') -Force
# import utils-setup for the Set-WslConf function
Import-Module (Convert-Path './modules/utils-setup') -Force
}

process {
Expand Down
4 changes: 2 additions & 2 deletions .assets/scripts/vg_certs_add.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ $ErrorActionPreference = 'Stop'
# set location to workspace folder
Push-Location "$PSScriptRoot/../.."

# import SetupUtils for the Set-WslConf function
Import-Module (Convert-Path './modules/SetupUtils') -Force
# import utils-setup for the Set-WslConf function
Import-Module (Convert-Path './modules/utils-setup') -Force

function Get-SshInstallScript ([string]$CertSaveStr) {
$script = [string]::Join("`n",
Expand Down
26 changes: 13 additions & 13 deletions BACKPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ against the rules below.
## Last ported through

```text
envy-nx commit: c859bba # bump on each backport PR; agent reads CHANGELOG entries newer than this
envy-nx tag: v1.4.0 # nearest released tag for human readability
ported on: 2026-05-01
envy-nx commit: 8e23552 # bump on each backport PR; agent reads CHANGELOG entries newer than this
envy-nx tag: v1.5.0 # nearest released tag for human readability
ported on: 2026-05-02
```

When you finish a backport PR, update all three lines and include the bump in
Expand Down Expand Up @@ -137,16 +137,16 @@ A blank "this repo" cell means **no equivalent - skip**.

| envy-nx | this repo |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `modules/InstallUtils/Functions/git.ps1` | `modules/InstallUtils/Functions/git.ps1` |
| `modules/do-common/Functions/common.ps1` | `modules/SetupUtils/Functions/common.ps1` |
| `modules/do-common/Functions/logs.ps1` | `modules/SetupUtils/Functions/logs.ps1` |
| `modules/do-common/Functions/certs.ps1` | `modules/SetupUtils/Functions/certs.ps1` |
| `modules/utils-install/Functions/git.ps1` | `modules/utils-install/Functions/git.ps1` |
| `modules/do-common/Functions/common.ps1` | `modules/utils-setup/Functions/common.ps1` |
| `modules/do-common/Functions/logs.ps1` | `modules/do-common/Functions/logs.ps1` |
| `modules/do-common/Functions/certs.ps1` | `modules/do-common/Functions/certs.ps1` |
| `modules/do-common/Functions/cli.ps1` | (no equivalent - evaluate on demand) |
| `modules/do-common/Functions/python.ps1` | (no equivalent) |
| `modules/do-common/Functions/dotnet.ps1` | (no equivalent) |
| `modules/do-common/Functions/net.ps1` | (no equivalent) |
| `modules/psm-windows/Functions/common.ps1` | `modules/InstallUtils/Functions/common.ps1` (`Invoke-CommandRetry`, `Join-Str`, `Test-IsAdmin`, `Update-SessionEnvironmentPath`) |
| `modules/SetupUtils/Functions/wsl.ps1` | `modules/SetupUtils/Functions/wsl.ps1` (only `Get-WslDistro`, `Set-WslConf` - scope helpers are nix-only) |
| `modules/psm-windows/Functions/common.ps1` | `modules/do-common/Functions/common.ps1` (`Invoke-CommandRetry`, `Join-Str`, `Test-IsAdmin`, `Update-SessionEnvironmentPath`) |
| `modules/utils-setup/Functions/wsl.ps1` | `modules/utils-setup/Functions/wsl.ps1` (only `Get-WslDistro`, `Set-WslConf` - scope helpers are nix-only) |
| `modules/{do-az,do-linux,aliases-git,aliases-kubectl}/...` | (no equivalent - these are vendored in envy-nx; this repo clones `szymonos/ps-modules` at runtime in `linux_setup.sh`. See *Module layout difference*) |

### Shell config
Expand Down Expand Up @@ -251,7 +251,7 @@ When porting Pester tests, adapt the dot-source path:

```text
envy-nx: . $PSScriptRoot/../../modules/do-common/Functions/common.ps1
this repo: . $PSScriptRoot/../../modules/SetupUtils/Functions/common.ps1
this repo: . $PSScriptRoot/../../modules/utils-setup/Functions/common.ps1
```

When porting bats tests, adapt the source directive:
Expand Down Expand Up @@ -331,8 +331,8 @@ Practical implication: when envy-nx changes a function in `modules/do-common/`,
the actual fix lives upstream in `szymonos/ps-modules`. envy-nx's vendored
copy is a snapshot. To port the fix to this repo:

1. Apply it to the corresponding function in `modules/SetupUtils/` or
`modules/InstallUtils/` (the module names this repo uses pre-clone), AND
1. Apply it to the corresponding function in `modules/utils-setup/` or
`modules/utils-install/` (the module names this repo uses pre-clone), AND
2. Optionally raise the same fix in `szymonos/ps-modules` (out of scope for
this doc; mention in the PR body if relevant)

Expand All @@ -347,7 +347,7 @@ envy-nx CHANGELOG entry: *added Pester tests for `Get-LogLine` covering the
2. Copy to `tests/pester/GetLogLine.Tests.ps1`
3. Change the dot-source line:
`. $PSScriptRoot/../../modules/do-common/Functions/logs.ps1`
→ `. $PSScriptRoot/../../modules/SetupUtils/Functions/logs.ps1`
→ `. $PSScriptRoot/../../modules/do-common/Functions/logs.ps1`
4. Run `pwsh -nop -c 'Invoke-Pester tests/pester/GetLogLine.Tests.ps1'`
5. Commit

Expand Down
Loading
Loading