Skip to content

Commit fe0d086

Browse files
committed
Correct the ReadMe a bit
1 parent f7dffc8 commit fe0d086

File tree

1 file changed

+62
-44
lines changed

1 file changed

+62
-44
lines changed

ReadMe.md

Lines changed: 62 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,70 @@ In service of this goal, we intend to produce:
1717

1818
## The ModuleBuilder module
1919

20-
This module is the first concrete step in the project (although it currently consists of only two commands). It represents the collaboration of several MVPs and module authors who had each written their own version of these tools for themselves, and have now decided to collaborate on creating a shared toolset. We are each using the patterns and tools that are represented here, and are committed to helping others to succeed at doing so.
20+
This module is the main output of the project, consisting of one primary command: `Build-Module` and a few helpers to translate input and output line numbers. It represents the collaboration of several module authors who had each written their own version of these tools for themselves, and have now decided to collaborate on creating a shared tool set. We are each using the patterns and tools that are represented here, and are committed to helping others to succeed at doing so.
21+
22+
### What's in the module so far
23+
24+
#### Build-Module
25+
26+
Builds a script module from a source project containing one file per function in `Public` and `Private` folders.
27+
28+
The `Build-Module` command is a build task for PowerShell script modules that supports [incremental builds](https://docs.microsoft.com/en-us/visualstudio/msbuild/incremental-builds).
29+
30+
#### Convert-CodeCoverage
31+
32+
Takes the output from `Invoke-Pester -Passthru` run against the build output, and converts the code coverage report to the source lines.
33+
34+
#### ConvertFrom-SourceLineNumber
35+
36+
Converts a line number from a source file to the corresponding line number in the built output.
37+
38+
#### ConvertTo-SourceLineNumber
39+
40+
Converts a line number from the built output to the corresponding file and line number in the source.
41+
42+
#### Convert-Breakpoint
43+
44+
Convert any breakpoints on source files to module files _and vice-versa_.
45+
46+
## Organizing Your Module
47+
48+
For best results, you need to organize your module project similarly to how this project is organized. It doesn't have to be exact, because nearly all of our conventions can be overriden, but the module _is_ opinionated, so if you follow the conventions, it should feel wonderfully automatic.
49+
50+
1. Create a `source` folder with a `build.psd1` file and your module manifest in it
51+
2. In the `build.psd1` specify the relative **Path** to your module's manifest, e.g. `@{ Path = "ModuleBuilder.psd1" }`
52+
3. In your manifest, make sure a few values are not commented out. You can leave them empty, because they'll be overwritten:
53+
- `FunctionsToExport` will be updated with the _file names_ that match the `PublicFilter`
54+
- `AliasesToExport` will be updated with the values from `[Alias()]` attributes on commands
55+
- `Prerelease` and `ReleaseNotes` in the `PSData` hash table in `PrivateData`
56+
57+
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.
58+
59+
1. By convention, use folders named "Classes" (and/or "Enum"), "Private", and "Public"
60+
2. By convention, the functions in "Public" will be exported from the module (you can override the `PublicFilter`)
61+
3. To force classes to be in a certain order, you can prefix their file names with numbers, like `01-User.ps1`
62+
63+
There are a _lot_ of conventions in `Build-Module`, expressed as default values for its parameters. These defaults are documented in the help for Build-Module. You can override any parameter defaults by adding keys to the `build.psd1` file with your preferences, or by passing the values to the `Build-Module` command directly.
64+
65+
## A note on build tools
66+
67+
There are several PowerShell build frameworks available. The build task in ModuleBuilder doesn't particularly endorse or interoperate with any of them, but it does accomplish a particular task that is needed by all of them.
68+
69+
A good build framework needs to support [incremental builds](https://docs.microsoft.com/en-us/visualstudio/msbuild/incremental-builds) and have a way to define build targets which have dependencies on other targets, such that it can infer the [target build order](https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-targets#target-build-order).
70+
71+
A good build framework should also include pre-defined tasks for most common build targets, including restoring dependencies, cleaning old output, building and assembling a module from source, testing that module, and publishing the module for public consumption. Our `Build-Module` command, for instance, is just one task of several which would be needed for a build target for a PowerShell script module.
72+
73+
We are currently using the [Invoke-Build](https://github.com/nightroman/Invoke-Build) and [earthly](https://docs.earthly.dev/) to build this module.
2174

2275
### Building from source
2376

2477
[![Build Status](https://github.com/PoshCode/ModuleBuilder/actions/workflows/build.yml/badge.svg)](https://github.com/PoshCode/ModuleBuilder/actions/workflows/build.yml)
2578

26-
The easiest, fastest build uses [earthly](https://docs.earthly.dev/). Earthly builds use containers to ensure tools are available, and to cache their output. On Windows, it requires WSL2, Docker Desktop, and of course, the earthly CLI. If you already have those installed, you can just check out this repository and run `earthly +test` to build and run the tests.
79+
The easiest, fastest build uses [earthly](https://docs.earthly.dev/). Earthly builds use containers to ensure tools are available, parallelize steps, and to cache their output. On Windows, it requires WSL2, Docker Desktop, and of course, the earthly CLI. If you already have those installed, you can just check out this repository and run `earthly +test` to build and run the tests.
2780

2881
```powershell
2982
git clone https://github.com/PoshCode/ModuleBuilder.git
30-
cd Modulebuilder
83+
cd ModuleBuilder
3184
earthly +test
3285
```
3386

@@ -40,14 +93,14 @@ git clone https://github.com/PoshCode/ModuleBuilder.git
4093
git clone https://github.com/PoshCode/Tasks.git
4194
```
4295

43-
As long as you have dotnet preinstalled, the `Build.build.ps1` script will use the shared [Tasks\_Bootstrap.ps1](https://github.com/PoshCode/Tasks/blob/main/_Bootstrap.ps1) to install the other dependencies (see [RequiredModules.psd1](https://github.com/PoshCode/ModuleBuilder/blob/main/RequiredModules.psd1)) and will then use [Invoke-Build](https://github.com/nightroman/Invoke-Build) and [Pester](https://github.com/Pester/Pester) to build and test the module.
96+
Once you've cloned both, the `Build.build.ps1` script will use the shared [Tasks\_Bootstrap.ps1](https://github.com/PoshCode/Tasks/blob/main/_Bootstrap.ps1) to install the other dependencies (see [RequiredModules.psd1](https://github.com/PoshCode/ModuleBuilder/blob/main/RequiredModules.psd1)), including [dotnet](https://dot.net), and will use [Invoke-Build](https://github.com/nightroman/Invoke-Build) and [Pester](https://github.com/Pester/Pester) to build and test the module.
4497

4598
```powershell
46-
cd Modulebuilder
99+
cd ModuleBuilder
47100
./Build.build.ps1
48101
```
49102

50-
This _should_ work on Windows, Linux, and MacOS, but I only test the process on Windows, and in the Linux containers via earthly.
103+
This _should_ work on Windows, Linux, or MacOS. I test the build process on Windows, and in CI we run it in the Linux containers via earthly, and we run the full Pester test suit on all three platforms.
51104

52105
#### The old-fashioned way
53106

@@ -58,44 +111,6 @@ You _can_ build the module without any additional tools (and without running tes
58111
./test.ps1
59112
```
60113

61-
#### `Build-Module`
62-
63-
Builds a script module from a source project containing one file per function in `Public` and `Private` folders.
64-
65-
The `Build-Module` command is a build task for PowerShell script modules that supports [incremental builds](https://docs.microsoft.com/en-us/visualstudio/msbuild/incremental-builds).
66-
67-
#### `Convert-CodeCoverage`
68-
69-
Takes the output from `Invoke-Pester -Passthru` run against the build output, and converts the code coverage report to the source lines.
70-
71-
## A note on build tools
72-
73-
There are several PowerShell build frameworks available. The build task in ModuleBuilder doesn't particularly endorse or interoperate with any of them, but it does accomplish a particular task that is needed by all of them.
74-
75-
A good build framework needs to support [incremental builds](https://docs.microsoft.com/en-us/visualstudio/msbuild/incremental-builds) and have a way to define build targets which have dependencies on other targets, such that it can infer the [target build order](https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-targets#target-build-order).
76-
77-
A good build framework should also include pre-defined tasks for most common build targets, including restoring dependencies, cleaning old output, building and assembling a module from source, testing that module, and publishing the module for public consumption. Our `Build-Module` command, for instance, is just one task of several which would be needed for a build target for a PowerShell script module.
78-
79-
80-
## Organizing Your Module
81-
82-
For best results, you need to organize your module project similarly to how this project is organized. It doesn't have to be exact, because nearly all of our conventions can be overriden, but the module *is* opinionated, so if you follow the conventions, it should feel wonderfully automatic.
83-
84-
1. Create a `source` folder with a `build.psd1` file and your module manifest in it
85-
2. In the `build.psd1` specify the relative **Path** to your module's manifest, e.g. `@{ Path = "ModuleBuilder.psd1" }`
86-
3. In your manifest, make sure a few values are not commented out. You can leave them empty, because they'll be overwritten:
87-
- `FunctionsToExport` will be updated with the _file names_ that match the `PublicFilter`
88-
- `AliasesToExport` will be updated with the values from `[Alias()]` attributes on commands
89-
- `Prerelease` and `ReleaseNotes` in the `PSData` hashtable in `PrivateData`
90-
91-
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.
92-
93-
1. By convention, use folders named "Classes" (and/or "Enum"), "Private", and "Public"
94-
2. By convention, the functions in "Public" will be exported from the module (you can override the `PublicFilter`)
95-
3. To force classes to be in a certain order, you can prefix their file names with numbers, like `01-User.ps1`
96-
97-
There are a *lot* of conventions in `Build-Module`, expressed as default values for its parameters. These defaults are documented in the help for Build-Module. You can override any parameter to `Build-Module` by passing it, or by adding keys to the `build.psd1` file with your preferences.
98-
99114
## Changelog
100115

101116
### 3.0.0 - Now with better alias support
@@ -104,3 +119,6 @@ Starting with this release, ModuleBuilder will automatically export aliases from
104119

105120
Additionally, the `Build-Module` command now _explicitly sorts_ the source files into alphabetical order, to ensure consistent behavior regardless of the native order of the underlying file system. This is technically also a breaking change, but it's unlikely to affect anyone except the people whose builds didn't work on non-Windows systems because of the previous behavior.
106121

122+
### 3.1.0 - Now allows help outside the top of script commands
123+
124+
Starting with this release, ModuleBuilder adds an empty line between the `#REGION filename` comment lines it injects, and the content of the files. This allows PowerShell to recognize help comments that are at the top of each file (outside the function block).

0 commit comments

Comments
 (0)