-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserAdminModule.psm1
More file actions
67 lines (58 loc) · 3.4 KB
/
UserAdminModule.psm1
File metadata and controls
67 lines (58 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#requires -Version 5.1
<#
UserAdminModule.psm1 — Root module entry point
================================================
Structure:
Private/ — internal helpers (Get-UserAdminModuleConfig)
Public/ — exported base framework functions (5 functions)
Shell/ — bundled UX submodule, loaded with -Global
profiles/ — profile scripts for users to dot-source
resources/ — config data and templates
Exported functions:
Import-PersonalModules — dynamic category importer (tab-completion)
Invoke-PersonalModulesMenu — interactive PSMenu multi-select
New-PSM1Module — submodule folder scaffolder
Invoke-FunctionIndexRegeneration — rebuilds FunctionIndex.json/.md
Initialize-UserAdminModule — first-run setup / config writer
Private helper (module-scoped, NOT exported):
Get-UserAdminModuleConfig — reads $env:APPDATA\UserAdminModule\config.json
Shell submodule is loaded with -Global so its exported functions (Set-PromptisAdmin,
Show-IsAdminOrNot, Set-ConsoleConfig, etc.) are available directly in the user's
session after Import-Module UserAdminModule.
NOTE: Public functions that discover submodules reference $script:UAMModuleRoot
(set below) instead of $PSScriptRoot, because after moving to Public/ the file's
$PSScriptRoot would point to the Public/ subdirectory, not the module root.
#>
# ── Module root — set FIRST; used by Public functions for submodule discovery ─
$script:UAMModuleRoot = $PSScriptRoot
# ── Private helpers (must load before Public functions are parsed) ─────────────
$_privateScripts = @( Get-ChildItem -Path "$PSScriptRoot\Private\*.ps1" -ErrorAction SilentlyContinue )
foreach ($_script in $_privateScripts) {
. $_script.FullName
}
Remove-Variable _privateScripts, _script -ErrorAction SilentlyContinue
# ── Public base framework functions ───────────────────────────────────────────
$_publicScripts = @( Get-ChildItem -Path "$PSScriptRoot\Public\*.ps1" -ErrorAction SilentlyContinue )
foreach ($_script in $_publicScripts) {
. $_script.FullName
}
Remove-Variable _publicScripts, _script -ErrorAction SilentlyContinue
# ── Shell submodule (bundled UX layer) ────────────────────────────────────────
# Loaded with -Global so its functions reach the user's session directly.
$_shellModule = Join-Path $PSScriptRoot 'Shell\Shell.psm1'
if (Test-Path $_shellModule) {
Import-Module $_shellModule -Force -DisableNameChecking -Global -ErrorAction SilentlyContinue
}
else {
Write-Warning 'UserAdminModule: Shell submodule not found. Prompt helpers will be unavailable.'
}
Remove-Variable _shellModule -ErrorAction SilentlyContinue
# ── Exports ───────────────────────────────────────────────────────────────────
# Get-UserAdminModuleConfig is intentionally NOT exported — private module helper only.
Export-ModuleMember -Function @(
'Import-PersonalModules'
'Invoke-PersonalModulesMenu'
'New-PSM1Module'
'Invoke-FunctionIndexRegeneration'
'Initialize-UserAdminModule'
)