Skip to content

Commit c9b7834

Browse files
author
James Brundage
committed
feat: Turtle module scaffolding ( Fixes #1 )
1 parent c8ed7d6 commit c9b7834

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

Turtle.psd1

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
@{
2+
# Script module or binary module file associated with this manifest.
3+
RootModule = 'Turtle.psm1'
4+
# Version number of this module.
5+
ModuleVersion = '0.1'
6+
# ID used to uniquely identify this module
7+
GUID = '80a19066-8558-4a56-a279-88464ef47ac8'
8+
# Author of this module
9+
Author = 'JamesBrundage'
10+
# Company or vendor of this module
11+
CompanyName = 'Start-Automating'
12+
# Copyright statement for this module
13+
Copyright = '2025 Start-Automating'
14+
# Type files (.ps1xml) to be loaded when importing this module
15+
TypesToProcess = @('Turtle.types.ps1xml')
16+
# Format files (.ps1xml) to be loaded when importing this module
17+
# FormatsToProcess = @()
18+
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
19+
FunctionsToExport = '*'
20+
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
21+
CmdletsToExport = '*'
22+
# Variables to export from this module
23+
VariablesToExport = '*'
24+
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
25+
AliasesToExport = '*'
26+
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
27+
PrivateData = @{
28+
PSData = @{
29+
# Tags applied to this module. These help with module discovery in online galleries.
30+
Tags = 'PowerShell', 'Turtle', 'SVG', 'Graphics', 'Drawing', 'L-System', 'Fractal'
31+
# A URL to the main website for this project.
32+
ProjectURI = 'https://github.com/PowerShellWeb/Turtle'
33+
# A URL to the license for this module.
34+
LicenseURI = 'https://github.com/PowerShellWeb/Turtle/blob/main/LICENSE'
35+
}
36+
}
37+
38+
# HelpInfo URI of this module
39+
# HelpInfoURI = ''
40+
41+
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
42+
# DefaultCommandPrefix = ''
43+
44+
}
45+

Turtle.psm1

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
$commandsPath = Join-Path $PSScriptRoot Commands
2+
:ToIncludeFiles foreach ($file in (Get-ChildItem -Path "$commandsPath" -Filter "*-*" -Recurse)) {
3+
if ($file.Extension -ne '.ps1') { continue } # Skip if the extension is not .ps1
4+
foreach ($exclusion in '\.[^\.]+\.ps1$') {
5+
if (-not $exclusion) { continue }
6+
if ($file.Name -match $exclusion) {
7+
continue ToIncludeFiles # Skip excluded files
8+
}
9+
}
10+
. $file.FullName
11+
}
12+
13+
$myModule = $MyInvocation.MyCommand.ScriptBlock.Module
14+
$ExecutionContext.SessionState.PSVariable.Set($myModule.Name, $myModule)
15+
$myModule.pstypenames.insert(0, $myModule.Name)
16+
17+
New-PSDrive -Name $MyModule.Name -PSProvider FileSystem -Scope Global -Root $PSScriptRoot -ErrorAction Ignore
18+
19+
if ($home) {
20+
$MyModuleProfileDirectory = Join-Path ([Environment]::GetFolderPath("LocalApplicationData")) $MyModule.Name
21+
if (-not (Test-Path $MyModuleProfileDirectory)) {
22+
$null = New-Item -ItemType Directory -Path $MyModuleProfileDirectory -Force
23+
}
24+
New-PSDrive -Name "My$($MyModule.Name)" -PSProvider FileSystem -Scope Global -Root $MyModuleProfileDirectory -ErrorAction Ignore
25+
}
26+
27+
# Set a script variable of this, set to the module
28+
# (so all scripts in this scope default to the correct `$this`)
29+
$script:this = $myModule
30+
31+
#region Custom
32+
#endregion Custom
33+
34+
Export-ModuleMember -Alias * -Function * -Variable $myModule.Name
35+
36+

0 commit comments

Comments
 (0)