Skip to content

Commit

Permalink
Converted repos to a module.
Browse files Browse the repository at this point in the history
Signed-off-by: sharpninja <ninja@thesharp.ninja>
  • Loading branch information
sharpninja committed Jun 26, 2023
1 parent cd75e0d commit 8162785
Show file tree
Hide file tree
Showing 10 changed files with 1,598 additions and 1,572 deletions.
1,092 changes: 0 additions & 1,092 deletions PackageManagers.ps1

This file was deleted.

1,552 changes: 1,552 additions & 0 deletions SnippetsManager.psm1

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Windows-ReadmeTest.ps9
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ try {
$exclusions += 'common.ps1'
Write-Verbose -Verbose:$MasterVerbose -Message "[$profileScript] Exclusions: $exclusions"

$snippets = Get-ChildItem *.ps1 -Verbose:$MasterVerbose -Exclude $exclusions
$snippets = Get-ChildItem *.ps1 -Verbose:$MasterVerbose -Exclude $exclusions | Sort-Object Name

$thirdPartyPath = $env:Snippets + '/3rdParty'

if (Test-Path $thirdPartyPath) {
$thirdParty = Get-ChildItem *.ps1 -Path $thirdPartyPath -Recurse -Verbose:$MasterVerbose -Exclude $exclusions

$snippets += $thirdParty
}

Expand Down
18 changes: 18 additions & 0 deletions _repos.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
param([switch]$VerboseSwitch = $false)

# $Verbose=$true -or $VerboseSwitch
$Verbose = $VerboseSwitch
# Write-Verbose "[$script] [$env:SnippetsInitialized] -not `$env:SnippetsInitialized: $(-not $env:SnippetsInitialized)" -Verbose:$Verbose
$script = $MyInvocation.MyCommand

# C:\Users\kingd\OneDrive\Documents\PowerShell\Snippets\PackageManagers.ps1
$packageManagers = Get-ChildItem SnippetsManager.psm1 -Path $env:Snippets

if (-not $packageManagers)
{
throw [ErrorRecord]::new("Cannot locate ``SnippetsManager.psm1`` in ``$env:Snippets``");
}

Import-Module $packageManagers -Verbose

Write-Verbose "Executing [$script]" -Verbose:$Verbose
8 changes: 8 additions & 0 deletions common.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
$utilities = Get-Module Microsoft.PowerShell.Utility -ErrorAction SilentlyContinue

if(-not $utilities){
Install-Module Microsoft.PowerShell.Utility -AllowClobber -Scope CurrentUser -AcceptLicense -Force
}

Import-Module Microsoft.PowerShell.Utility

param([switch]$VerboseSwitch = $false)

function Set-SnippetsLocation {
Expand Down
16 changes: 6 additions & 10 deletions devmode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,27 @@ $Verbose = $VerboseSwitch
# Write-Verbose "[$script] [$env:SnippetsInitialized] -not `$env:SnippetsInitialized: $(-not $env:SnippetsInitialized)" -Verbose:$Verbose
$script = $MyInvocation.MyCommand

if (-not $env:SnippetsInitialized) {
if (-not $env:SnippetsInitialized) {
$fileInfo = New-Object System.IO.FileInfo (Get-Item $PSScriptRoot).FullName
$path = $fileInfo.Directory.FullName;
. $path/Snippets/common.ps1;
Initialize-Snippets -Verbose:$Verbose
. $path/Snippets/common.ps1;
Initialize-Snippets -Verbose:$Verbose
}

if ($env:IsWindows -ieq 'true') {
try {
$vswhere = Get-Command vswhere -ErrorAction SilentlyContinue

if (-not($vswhere)) {
$winget = get-command winget -ErrorAction SilentlyContinue
Invoke-Any install Microsoft.VisualStudio.Locator -Exact -managerCode 'wg' -VerboseSwitch

if (-not($winget)) {
throw "winget is not installed";
}

& $winget install Microsoft.VisualStudio.Locator
refreshenv

$vswhere = Get-Command vswhere -ErrorAction SilentlyContinue

if (-not($vswhere)) {
throw "Could not install vswhere";
}
}
}

function Start-DevMode {
Expand Down
3 changes: 3 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
remote_theme: pages-themes/architect@v0.2.0
plugins:
- jekyll-remote-theme # add this line to the plugins list if you already have one
1 change: 1 addition & 0 deletions docs/assets/css/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "{{ site.theme }}";
8 changes: 8 additions & 0 deletions docs/data/mydoc_sidebar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
docs_list_title: PS Snippets Links
docs:

- title: GitHub Source
url: https://github.com/ps-services/snippets

- title: Tutorial
url: https://thesharp.ninja/powershell-snippets-tutorial-de75728ba5b0

0 comments on commit 8162785

Please sign in to comment.