Skip to content

dbroeglin/Forge.Module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build status

Forge Generator for PowerShell modules

This module contains Forge generators for PowerShell modules. New-ForgeModule generates a new module and New-ForgeModuleFunction generates a new function inside an already created module.

The generator is still quite new (and probably a bit opinionated) parts of the structure come from the excellent https://github.com/devblackops/NetScaler module and quite a bit of the rest comes from another similar project https://github.com/PowerShell/Plaster

Installation

Install-Module Forge.Module

Example

The following commands should generate a module named PoshTodo:

New-ForgeModule -Name PoshTodo -License MIT -Author Léa -Email [email protected] -Layout ModuleName

Would create, in the current directory a scaffold for module PoshTodo with the following structure:

./PoshTodo
├── LICENSE
├── PoshTodo
│   ├── PoshTodo.psd1
│   └── PoshTodo.psm1
├── README.md
└── Tests

A skeleton function with associated Pester test file can then be generated by executing:

cd PoshTodo
New-ForgeModuleFunction -Name New-PoshTodo

Which produces the following result:

./PoshTodo
├── LICENSE
├── PoshTodo
│   ├── New-PoshTodo.ps1
│   ├── PoshTodo.psd1
│   └── PoshTodo.psm1
├── README.md
└── Tests
    ├── Manifest.Tests.ps1
    └── New-PoshTodo.Tests.ps1

Adding the -Editor VSCode parameter will generate workspace configuration files for the Visual Studio Code editor. For instance, it will generate a list of task that allow to run tests and other lifecycle operations from inside the editor.

Depending on your preferences the module can be generated with two different build systems (or none if you do not need or want one).

To generate PSake integration:

New-ForgeModule -Name PoshTodo -Build PSake 

To generate InvokeBuild integration:

New-ForgeModule -Name PoshTodo -Build InvokeBuild

With all options activated we get:

New-ForgeModule -Name PoshTodo -License MIT -Author Léa -Email [email protected] `
    -Editor VSCode -Build PSake `
    -Description "A Powershell TODO list handler" `
    -Layout ModuleName

Which would generate the following project:

./PoshTodo
├── LICENSE
├── PoshTodo
│   ├── PoshTodo.psd1
│   └── PoshTodo.psm1
├── README.md
├── ScriptAnalyzerSettings.psd1
├── Tests
│   └── Manifest.Tests.ps1
├── build.ps1
├── build.psake.ps1
└── build.settings.ps1    

Dependencies

Run time

At run time, the following modules are required:

Install-Module Forge

Build time

Additionally, at build time, the following modules are required:

Install-Module Pester