You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🌟 [Major]: Add functionality to export variables (#57)
## Description
- Fixes #58
- Restructure expected module folder structure.
- variables established under `variables` with a separate `private` and
`public` folders.
- To comply to the same structure, adjusted `classes` and `functions` to
the same structure.
- items under the `public` folders will be exported, the others are kept
in the module scope.
- Swap to use `GitHub-Script@v1`, instead of pure inline scripts.
## Type of change
<!-- Use the check-boxes [x] on the options that are relevant. -->
- [ ] 📖 [Docs]
- [ ] 🪲 [Fix]
- [ ] 🩹 [Patch]
- [ ] ⚠️ [Security fix]
- [ ] 🚀 [Feature]
- [x] 🌟 [Breaking change]
## Checklist
<!-- Use the check-boxes [x] on the options that are relevant. -->
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
Copy file name to clipboardExpand all lines: README.md
+26-20Lines changed: 26 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,9 +18,9 @@ This GitHub Action is a part of the [PSModule framework](https://github.com/PSMo
18
18
During the build process the following steps are performed:
19
19
20
20
1. Copies the source code of the module to an output folder.
21
-
1. Builds the module manifest file based of info on the GitHub repository and source code. Read the [Module Manifest](#module-manifest) section for more information.
22
-
1. Builds the root module (.psm1) file by combining source code and adding automation into the root module file. Read the [Root module](#root-module) section for more information.
23
-
1. Builds the module documentation using platyPS and comment based help in the source code. Read the [Module documentation](#module-documentation) section for more information.
21
+
1. Builds the module manifest file based of info on the GitHub repository and source code. For more information, please read the [Module Manifest](#module-manifest) section.
22
+
1. Builds the root module (.psm1) file by combining source code and adding automation into the root module file. For more information, please read the [Root module](#root-module) section.
23
+
1. Builds the module documentation using platyPS and comment based help in the source code. For more information, please read the [Module documentation](#module-documentation) section.
24
24
25
25
## Usage
26
26
@@ -33,28 +33,34 @@ During the build process the following steps are performed:
33
33
34
34
## Root module
35
35
36
-
The `src` folder may contain a 'root module' file. If present, the build function will disregard this file
37
-
and build a new root module file based on the source code in the module folder.
36
+
The `src` folder may contain a 'root module' file. If present, the build function will disregard this file and build a new root module file based on
37
+
the source code in the module folder.
38
38
39
-
The root module file is the main file that is loaded when the module is imported.
40
-
It is built from the source code files in the module folder in the following order:
39
+
The root module file is the main file that is loaded when the module is imported. It is built from the source code files in the module folder in the
40
+
following order:
41
41
42
-
1. Adds module headers from `header.ps1` if it exists and removes the file from the module folder.
43
-
1. Adds data loader automation that loads files from the `data` folder as variables in the module scope, if it exists. The variables are available using the ´$script:<filename>´ syntax.
44
-
1. Adds content from subfolders, if they exists, and removes them from the module folder in the following order:
42
+
1. Adds a module header from `header.ps1` if it exists and removes the file from the module folder.
43
+
1. Adds a data loader that loads files from the `data` folder as variables in the module scope, if the folder exists. The variables are available
44
+
using the `$script:<filename>` syntax.
45
+
1. Adds content from subfolders into the root module file and removes them from the module folder in the following order:
45
46
-`init`
46
-
-`classes`
47
-
-`private`
48
-
-`public`
47
+
-`classes/private`
48
+
-`classes/public`
49
+
-`functions/private`
50
+
-`functions/public`
51
+
-`variables/private`
52
+
-`variables/public`
49
53
-`*.ps1` on module root
50
-
1. Adds a `class` and `enum` exporter that exports all classes and enums in the module to the caller session, using TypeAccelerators.
51
-
1. Adds the `Export-ModuleMember` function to the end of the file, to make sure that only the functions, cmdlets, variables and aliases that are defined in the module are exported.
54
+
1. Adds a `class` and `enum` exporter that exports the ones from `classes/public` folder to the caller session, using [TypeAccelerators](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_classes?view=powershell-7.4#exporting-classes-with-type-accelerators).
55
+
1. Adds the `Export-ModuleMember` function to the end of the file, to make sure that only the functions, cmdlets, variables and aliases that are
56
+
defined in the `public` folders are exported.
52
57
53
58
## Module manifest
54
59
55
60
The module manifest file is the file that describes the module and its content. It is used by PowerShell to load the module and its prerequisites.
56
-
The file also contains important metadata that is used by the PowerShell Gallery. If a file exists in the source code folder `src` it will be used as a base for the module manifest file.
57
-
Most of the values in the module manifest file are calculated during the build process however some of these will not be touched if specified in the source manifest file.
61
+
The file also contains important metadata that is used by the PowerShell Gallery. If a file exists in the source code folder `src` it will be used as
62
+
a base for the module manifest file. Most of the values in the module manifest file will be calculated during the build process however some of these
63
+
will not be touched if specified in the source manifest file.
58
64
59
65
During the module manifest build process the following steps are performed:
60
66
@@ -72,7 +78,7 @@ During the module manifest build process the following steps are performed:
72
78
1. Get the list of types to process by searching for `*.Types.ps1xml` files in the entire module source folder and set the `TypesToProcess` property in the manifest.
73
79
1. Get the list of formats to process by searching for `*.Format.ps1xml` files in the entire module source folder and set the `FormatsToProcess` property in the manifest.
74
80
1. Get the list of DSC resources to export by searching for `*.psm1` files in the `resources` folder and set the `DscResourcesToExport` property in the manifest.
75
-
1. Get the list of functions, cmdlets, aliases, and variables to export and set the respective properties in the manifest.
81
+
1. Get the list of functions, cmdlets, aliases, and variables from the respective `<type>\public` folder set the respective properties in the manifest.
76
82
1. Get the list of modules by searching for all `*.psm1` files in the entire module source folder, excluding the root module and set the `ModuleList` property in the manifest.
77
83
1. Gather information from source files to update `RequiredModules`, `PowerShellVersion`, and `CompatiblePSEditions` properties.
78
84
1. The following values are gathered from the GitHub repository:
@@ -114,8 +120,8 @@ Linking the description to the module manifest file might show more how this wor
114
120
NestedModules = @() # Get from modules\*.psm1.
115
121
FunctionsToExport = @() # Get from public\*.ps1.
116
122
CmdletsToExport = @() # Get from manifest file, @() if not provided.
117
-
VariablesToExport = @() # To be automated, currently adds '@()' to the manifest file.
118
-
AliasesToExport = '*' # To be automated, currently adds '*' to the manifest file.
123
+
VariablesToExport = @() # Get from variables\public\*.ps1.
124
+
AliasesToExport = '*' # Get from functions\public\*.ps1.
119
125
DscResourcesToExport = @() # Get from resources\*.psm1.
120
126
ModuleList = @() # Get from listing all .\*.psm1 files - Informational only.
121
127
FileList = @() # Get from listing all .\* files - Informational only.
0 commit comments