-
Notifications
You must be signed in to change notification settings - Fork 57
Dotnet template "ModuleBuilderModule" #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f10c530
Dotnet template ModuleBuilderModule
bravo-kernel 2f91df3
fix: make sure generated manifest is UTF-8 without BOM
bravo-kernel 5678541
feat: make utf-8 the .editorconfig standard
bravo-kernel e33ae9c
template: remove Configuration from RequiredModules
bravo-kernel 6e5612e
fix: add .psm1 extension to manifest RootModule
bravo-kernel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # ignore the build folder | ||
| Output/ |
37 changes: 37 additions & 0 deletions
37
Templates/Dotnet/ModuleBuilderModule/.template.config/template.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
| "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" | ||
| } | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
17
Templates/Dotnet/ModuleBuilderModule/dotnet-post-action.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?