Skip to content

Commit 12aafbf

Browse files
authored
Clean up module template
Merge pull request #80 from PoshCode/feature/dotnet-template
2 parents 1acd686 + d893f45 commit 12aafbf

5 files changed

Lines changed: 193 additions & 51 deletions

File tree

ReadMe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ For best results, you need to organize your module project similarly to how this
102102

103103
Once you start working on the module, you'll create sub-folders in source, and put script files in them with only **one** function in each file. You should name the files with _the same name_ as the function that's in them -- especially in the public folder, where we use the file name (without the extension) to determine the exported functions.
104104

105-
1. By convention, use folders named "Classes" (or "Enum"), "Private", and "Public"
105+
1. By convention, use folders named "Classes" (and/or "Enum"), "Private", and "Public"
106106
2. By convention, the functions in "Public" will be exported from the module
107107
3. To force classes to be in a certain order, you can prefix their file names with numbers, like `01-User.ps1`
108108

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,49 @@
11
{
22
"$schema": "http://json.schemastore.org/template",
3-
"identity": "PoshCode.ModuleBuilderModule",
3+
"identity": "PoshCode.ModuleBuilder.EmptyModule",
4+
"groupIdentity": "PoshCode.ModuleBuilder",
45
"author": "PoshCode",
56
"tags": {
67
"language": "Powershell",
78
"type": "project"
89
},
9-
"classifications": ["Powershell", "Modules"],
10-
"name": "ModuleBuilder Module Generator",
11-
"shortName": "ModuleBuilderModule",
10+
"classifications": ["Powershell", "Module"],
11+
"name": "PowerShell Module with ModuleBuilder",
12+
"shortName": "PSModuleBuilder",
13+
"sourceName": "ModuleBuilderModule",
14+
"placeholderFilename": ".gitkeep",
15+
"guids":["65a15d36-3f55-4916-ba8f-26f18775e1b7"],
1216
"symbols": {
13-
"moduleName": {
14-
"type": "parameter",
15-
"datatype": "string",
16-
"description": "Name of your new Powershell Module",
17-
"replaces": "{moduleName}",
18-
"isRequired": true
17+
"author": {
18+
"type": "parameter",
19+
"defaultValue": "Anonymous",
20+
"replaces": "Joel Bennett"
21+
},
22+
"company": {
23+
"type": "parameter",
24+
"defaultValue": "Unknown",
25+
"replaces": "PoshCode.org"
26+
},
27+
"description": {
28+
"type": "parameter",
29+
"defaultValue": "A useful module with a useless description",
30+
"replaces": "A ModuleBuilder Template Module"
31+
},
32+
"createdate": {
33+
"type": "generated",
34+
"generator": "now",
35+
"parameters": {
36+
"format": "yyyy-MM-dd"
37+
},
38+
"replaces": "2019-10-10"
39+
},
40+
"copyright": {
41+
"type": "generated",
42+
"generator": "now",
43+
"parameters": {
44+
"format": "yyyy"
45+
},
46+
"replaces": "2019"
1947
}
20-
},
21-
"postActions": [
22-
{
23-
"actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2",
24-
"args": {
25-
"executable": "powershell",
26-
"args": "./dotnet-post-action.ps1"
27-
},
28-
"manualInstructions": [
29-
{
30-
"text": "Generate Manifest"
31-
}
32-
],
33-
"continueOnError": false,
34-
"description ": "Generates a basic Module Manifest"
35-
}
36-
]
48+
}
3749
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Module manifest for module 'ModuleBuilderModule'
2+
# Generated by: Joel Bennett
3+
# Generated on: 2019-10-10
4+
@{
5+
# Script module or binary module file associated with this manifest.
6+
RootModule = 'ModuleBuilderModule.psm1'
7+
8+
# Version number of this module.
9+
ModuleVersion = '1.0.0'
10+
11+
# ID used to uniquely identify this module
12+
GUID = '65a15d36-3f55-4916-ba8f-26f18775e1b7'
13+
14+
# Author of this module
15+
Author = 'Joel Bennett'
16+
17+
# Company or vendor of this module
18+
CompanyName = 'PoshCode.org'
19+
20+
# Copyright statement for this module
21+
Copyright = '(c) 2019 Joel Bennett. All rights reserved.'
22+
23+
# Description of the functionality provided by this module
24+
Description = 'A ModuleBuilder Template Module'
25+
26+
# Private data available to the module
27+
PrivateData = @{
28+
# Additional metadata used by PowerShellGet for publishing
29+
PSData = @{
30+
# Prerelease string should be here, so ModuleBuilder can set it
31+
Prerelease = ''
32+
33+
# Release Notes have to be here, so ModuleBuilder can update them
34+
ReleaseNotes = '
35+
'
36+
37+
# Tags applied to this module in online galleries.
38+
Tags = @()
39+
40+
# A URL to the license for this module.
41+
# LicenseUri = ''
42+
43+
# A URL to the main website for this project.
44+
# ProjectUri = ''
45+
46+
# A URL to an icon representing this module.
47+
# IconUri = ''
48+
49+
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
50+
RequireLicenseAcceptance = $false
51+
52+
# Modules that are in RequiredModules which don't need to be installed by PowerShellGet
53+
# ExternalModuleDependencies = @()
54+
55+
} # End of PSData hashtable
56+
57+
} # End of PrivateData hashtable
58+
59+
# 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.
60+
FunctionsToExport = @()
61+
62+
# 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.
63+
CmdletsToExport = @()
64+
65+
# Variables to export from this module
66+
VariablesToExport = @()
67+
68+
# 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.
69+
AliasesToExport = @()
70+
71+
# DSC resources to export from this module
72+
# DscResourcesToExport = @()
73+
74+
# Modules that must be imported into the global environment prior to importing this module
75+
# RequiredModules = @()
76+
77+
# Assemblies that must be loaded prior to importing this module
78+
# RequiredAssemblies = @()
79+
80+
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
81+
# ScriptsToProcess = @()
82+
83+
# Type files (.ps1xml) to be loaded when importing this module
84+
# TypesToProcess = @()
85+
86+
# Format files (.ps1xml) to be loaded when importing this module
87+
# FormatsToProcess = @()
88+
89+
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
90+
# NestedModules = @()
91+
92+
# List of all modules packaged with this module
93+
# ModuleList = @()
94+
95+
# List of all files packaged with this module
96+
# FileList = @()
97+
98+
# HelpInfo URI of this module
99+
# HelpInfoURI = ''
100+
101+
# Supported PSEditions
102+
# CompatiblePSEditions = @()
103+
104+
# Minimum version of the Windows PowerShell engine required by this module
105+
# PowerShellVersion = ''
106+
107+
# Name of the Windows PowerShell host required by this module
108+
# PowerShellHostName = ''
109+
110+
# Minimum version of the Windows PowerShell host required by this module
111+
# PowerShellHostVersion = ''
112+
113+
# Minimum version of Microsoft .NET Framework required by this module.
114+
# This prerequisite is valid for the PowerShell Desktop edition only.
115+
# DotNetFrameworkVersion = ''
116+
117+
# Minimum version of the common language runtime (CLR) required by this module.
118+
# This prerequisite is valid for the PowerShell Desktop edition only.
119+
# CLRVersion = ''
120+
121+
# Processor architecture (None, X86, Amd64) required by this module
122+
# ProcessorArchitecture = ''
123+
124+
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
125+
# DefaultCommandPrefix = ''
126+
127+
}

Templates/Dotnet/ModuleBuilderModule/dotnet-post-action.ps1

Lines changed: 0 additions & 17 deletions
This file was deleted.

Templates/README.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,36 @@ generate new Powershell Modules following ModuleBuilder best practices and thus:
88

99
## Dotnet
1010

11-
After installing ModuleBuilder, users can use the `ModuleBuilderModule`
12-
[dotnet template](https://github.com/dotnet/templating) to generate
13-
new modules using:
11+
After cloning this repository (and assuming you have the dotnet SDK installed),
12+
you can install the ModuleBuilder templates from this folder by running:
1413

1514
```posh
16-
dotnet new ModuleBuilderModule -o GeneratedModule --moduleName MyGeneratedModule
15+
dotnet new -i ./
1716
```
1817

19-
or without user interaction:
18+
We need to publish this to nuget to make installing it easier.
19+
20+
Once you've installed the template(s), you can use the `PSModuleBuilder`
21+
[template](https://github.com/dotnet/templating) to generate a new module in an empty folder using:
22+
23+
```posh
24+
dotnet new PSModuleBuilder
25+
```
26+
27+
Or you can create the module folder with `-o` and set the module author, company and description like this:
28+
29+
```posh
30+
dotnet new PSModuleBuilder -o MyNewModule --author Jaykul --company PoshCode.org --description "My Brand New Module"
31+
```
32+
33+
Even better, you can create some defaults for yourself using the alias option:
34+
35+
```posh
36+
dotnet new -a psmo psmodulebuilder --author Jaykul --company PoshCode.org
37+
```
38+
39+
And then create a new module like this:
2040

2141
```posh
22-
dotnet new ModuleBuilderModule -o GeneratedModule --moduleName MyGeneratedModule --allow-scripts yes
42+
dotnet new psmo -o MyNewModule --description "My Brand New Module"
2343
```

0 commit comments

Comments
 (0)