Skip to content

Commit 78f5555

Browse files
committed
feat: Update modules functionality and functions
1 parent df2f474 commit 78f5555

File tree

3 files changed

+36
-28
lines changed

3 files changed

+36
-28
lines changed

Modules/modules.json

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,13 @@
11
[
2-
"0install",
3-
"BuildHelpers",
4-
"ChocolateyGet",
5-
"Dotted",
6-
"Foil",
7-
"GistProvider",
8-
"GitHubProvider",
9-
"InvokeBuild",
2+
"DockerCompletion",
103
"oh-my-posh",
11-
"Pester",
12-
"Plaster",
13-
"platyPS",
144
"posh-git",
155
"powershell-yaml",
16-
"PowerShellBuild",
176
"psake",
18-
"Pscx",
19-
"PSFzf",
20-
"PSScriptAnalyzer",
7+
"PSReadLine",
218
"PSWindowsUpdate",
22-
"PSWinSetup",
23-
"PSWinVitals",
249
"PSWriteColor",
25-
"RobocopyPS",
26-
"Sampler",
27-
"Stucco",
10+
"scoop-completion",
2811
"Terminal-Icons",
29-
"UtilityFunctions",
30-
"WinGet",
31-
"WinRegistry",
32-
"WslInterop",
3312
"ZLocation"
3413
]

Modules/modules.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- DockerCompletion
2+
- oh-my-posh
3+
- posh-git
4+
- powershell-yaml
5+
- psake
6+
- PSReadLine
7+
- PSWindowsUpdate
8+
- PSWriteColor
9+
- scoop-completion
10+
- Terminal-Icons
11+
- ZLocation

Profile/modules.ps1

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,28 @@ $env:POSH_GIT_ENABLED = $true
1717
# --------
1818

1919
Function Backup-Modules {
20-
$savefile = "$env:OneDrive\Documents\PowerShell\modules.json"
21-
if (Test-Path $savefile) { Rename-Item -Path $savefile -NewName ($savefile + ".bak") }
22-
$mods = Get-ChildItem -Path $env:OneDrive\Documents\PowerShell\Modules -Directory
23-
$mods.Name | ConvertTo-Json > $savefile
20+
$modpath = ($env:PSModulePath -split ";")[0]
21+
$ymlpath = "$modpath\modules.yml"
22+
$jsonpath = "$modpath\modules.json"
23+
$mods = (Get-ChildItem $modpath -Directory).Name
24+
If (!(Get-Module -Name powershell-yaml -ErrorAction SilentlyContinue)) {
25+
ConvertTo-Json $mods > $jsonpath
26+
} else {
27+
ConvertTo-Yaml -Data $mods -OutFile $ymlpath -Force
28+
}
29+
30+
}
31+
32+
Function Sync-Modules {
33+
$psdir = (Split-Path -Parent $profile)
34+
Set-Location $psdir
35+
git pull
36+
git add PowerShell/Modules/**
37+
git commit -m "config: Updated modules configurations"
38+
git-cliff -o "$HOME\Documents\CHANGELOG.md"
39+
git add CHANGELOG.md
40+
git commit -m "doc: update CHANGELOG.md for added modules"
41+
git push
2442
}
2543

2644
Function Restore-Modules {

0 commit comments

Comments
 (0)