Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Templates/Dotnet/ModuleBuilderModule/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# EditorConfig is awesome: http://EditorConfig.org
#
# Copied from https://github.com/PowerShell/PowerShellEditorServices/blob/master/.editorconfig

# top-most EditorConfig file
root = true

[*]
charset = utf-8
indent_style = space
insert_final_newline = true

[*.{cs}]
indent_size = 4
trim_trailing_whitespace = true

[*.{json}]
indent_size = 2
trim_trailing_whitespace = true

[*.{ps1,psm1,psd1}]
indent_size = 4
trim_trailing_whitespace = true

[*.{ps1xml,props,xml,yaml}]
indent_size = 2
4 changes: 4 additions & 0 deletions Templates/Dotnet/ModuleBuilderModule/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Define the line ending behavior of the different file extensions
# Set default behavior, in case users don't have core.autocrlf set.
* text=auto
* text eol=lf
2 changes: 2 additions & 0 deletions Templates/Dotnet/ModuleBuilderModule/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ignore the build folder
Output/
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "http://json.schemastore.org/template",
"identity": "PoshCode.ModuleBuilderModule",
"author": "PoshCode",
"tags": {
"language": "Powershell",
"type": "project"
},
"classifications": ["Powershell", "Modules"],
"name": "ModuleBuilder Module Generator",
"shortName": "ModuleBuilderModule",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a less verbose shortname here?

Suggested change
"shortName": "ModuleBuilderModule",
"shortName": "PSMBModule",

"symbols": {
"moduleName": {
"type": "parameter",
"datatype": "string",
"description": "Name of your new Powershell Module",
"replaces": "{moduleName}",
"isRequired": true
}
},
"postActions": [
{
"actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2",
"args": {
"executable": "powershell",
"args": "./dotnet-post-action.ps1"
},
"manualInstructions": [
{
"text": "Generate Manifest"
}
],
"continueOnError": false,
"description ": "Generates a basic Module Manifest"
}
]
}
17 changes: 17 additions & 0 deletions Templates/Dotnet/ModuleBuilderModule/GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
mode: Mainline
commit-message-incrementing: MergeMessageOnly
assembly-versioning-format: '{Major}.{Minor}.{Patch}.{env:BUILDCOUNT ?? 0}'
assembly-informational-format: '{NuGetVersionV2}+Build.{env:BUILDCOUNT ?? 0}.Date.{CommitDate}.Branch.{env:SAFEBRANCHNAME ?? unknown}.Sha.{Sha}'
next-version: 1.0.0
branches:
master:
increment: Patch
pull-request:
tag: rc
increment: Patch
features:
increment: Patch
regex: .*?/
source-branches:
- master
- features
28 changes: 28 additions & 0 deletions Templates/Dotnet/ModuleBuilderModule/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# {moduleName}

## Requirements

```posh
Install-Script -Name Install-RequiredModule
```

## Building your module

1. run `Install-RequiredModule`

2. add `.ps1` script files to the `Source` folder

3. run `Build-Module .\Source`

4. compiled module appears in the `Output` folder

## Versioning

ModuleBuilder will automatically apply the next semver version
if you have installed [gitversion](https://gitversion.readthedocs.io/en/latest/).

To manually create a new version run `Build-Module .\Source -SemVer 0.0.2`

## Additional Information

https://github.com/PoshCode/ModuleBuilder
5 changes: 5 additions & 0 deletions Templates/Dotnet/ModuleBuilderModule/RequiredModules.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# todo: add explanation
@{
ModuleBuilder = "1.*"
Pester = "[4.7.2, 5.0)"
}
Empty file.
Empty file.
Empty file.
Empty file.
14 changes: 14 additions & 0 deletions Templates/Dotnet/ModuleBuilderModule/Source/build.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -----------------------------------------------------------------------------
# ModuleBuilder configuration file. Use this file to override the default
# parameter values used by the `Build-Module` command when building the module.
#
# For a full list of supported arguments run `Get-Help Build-Module -Full`.
# -----------------------------------------------------------------------------

@{
Path = "{moduleName}.psd1"
VersionedOutputDirectory = $true
CopyDirectories = @(
'en-US'
)
}
Empty file.
Empty file.
17 changes: 17 additions & 0 deletions Templates/Dotnet/ModuleBuilderModule/dotnet-post-action.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<#
.SYNOPSIS
Powershell script used as dotnet template post action
#>
Set-StrictMode -Version Latest

# generate manifest
$manifestPath = "./Source/{moduleName}.psd1"
New-ModuleManifest -RootModule "{moduleName}.psm1" -Path $manifestPath -ModuleVersion 0.0.1

# convert manifest to UTF-8 without BOM
$content = Get-Content $manifestPath
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
[System.IO.File]::WriteAllLines($manifestPath, $content, $Utf8NoBomEncoding)

# delete self
Remove-Item ./dotnet-post-action.ps1
23 changes: 23 additions & 0 deletions Templates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generators

This directory contains (template based) generators that allow end-users to easily
generate new Powershell Modules following ModuleBuilder best practices and thus:

- folder structure
- default settings

## Dotnet

After installing ModuleBuilder, users can use the `ModuleBuilderModule`
[dotnet template](https://github.com/dotnet/templating) to generate
new modules using:

```posh
dotnet new ModuleBuilderModule -o GeneratedModule --moduleName MyGeneratedModule
```

or without user interaction:

```posh
dotnet new ModuleBuilderModule -o GeneratedModule --moduleName MyGeneratedModule --allow-scripts yes
```