Skip to content

Commit

Permalink
feat: Update modules functionality and functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jimbrig committed Oct 25, 2021
1 parent df2f474 commit 78f5555
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 28 deletions.
27 changes: 3 additions & 24 deletions Modules/modules.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,13 @@
[
"0install",
"BuildHelpers",
"ChocolateyGet",
"Dotted",
"Foil",
"GistProvider",
"GitHubProvider",
"InvokeBuild",
"DockerCompletion",
"oh-my-posh",
"Pester",
"Plaster",
"platyPS",
"posh-git",
"powershell-yaml",
"PowerShellBuild",
"psake",
"Pscx",
"PSFzf",
"PSScriptAnalyzer",
"PSReadLine",
"PSWindowsUpdate",
"PSWinSetup",
"PSWinVitals",
"PSWriteColor",
"RobocopyPS",
"Sampler",
"Stucco",
"scoop-completion",
"Terminal-Icons",
"UtilityFunctions",
"WinGet",
"WinRegistry",
"WslInterop",
"ZLocation"
]
11 changes: 11 additions & 0 deletions Modules/modules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- DockerCompletion
- oh-my-posh
- posh-git
- powershell-yaml
- psake
- PSReadLine
- PSWindowsUpdate
- PSWriteColor
- scoop-completion
- Terminal-Icons
- ZLocation
26 changes: 22 additions & 4 deletions Profile/modules.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,28 @@ $env:POSH_GIT_ENABLED = $true
# --------

Function Backup-Modules {
$savefile = "$env:OneDrive\Documents\PowerShell\modules.json"
if (Test-Path $savefile) { Rename-Item -Path $savefile -NewName ($savefile + ".bak") }
$mods = Get-ChildItem -Path $env:OneDrive\Documents\PowerShell\Modules -Directory
$mods.Name | ConvertTo-Json > $savefile
$modpath = ($env:PSModulePath -split ";")[0]
$ymlpath = "$modpath\modules.yml"
$jsonpath = "$modpath\modules.json"
$mods = (Get-ChildItem $modpath -Directory).Name
If (!(Get-Module -Name powershell-yaml -ErrorAction SilentlyContinue)) {
ConvertTo-Json $mods > $jsonpath
} else {
ConvertTo-Yaml -Data $mods -OutFile $ymlpath -Force
}

}

Function Sync-Modules {
$psdir = (Split-Path -Parent $profile)
Set-Location $psdir
git pull
git add PowerShell/Modules/**
git commit -m "config: Updated modules configurations"
git-cliff -o "$HOME\Documents\CHANGELOG.md"
git add CHANGELOG.md
git commit -m "doc: update CHANGELOG.md for added modules"
git push
}

Function Restore-Modules {
Expand Down

0 comments on commit 78f5555

Please sign in to comment.