Skip to content

Commit fbb1e4e

Browse files
committed
Revert "Merge pull request #10 from BrooksV/update-copy-projectresource"
This reverts commit 0b19ead, reversing changes made to ebcd978. Tracking these changes as new branch
1 parent 0b19ead commit fbb1e4e

File tree

5 files changed

+15
-75
lines changed

5 files changed

+15
-75
lines changed

README.md

Lines changed: 9 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Whether you're creating simple or robust modules, ModuleTools streamlines the pr
1515
[![ModuleTools@PowerShell Gallery][BadgeIOCount]][PSGalleryLink]
1616
![WorkFlow Status][WorkFlowStatus]
1717

18+
19+
1820
The structure of the ModuleTools module is meticulously designed according to PowerShell best practices for module development. While some design decisions may seem unconventional, they are made to ensure that ModuleTools and the process of building modules remain straightforward and easy to manage.
1921

2022
> [!IMPORTANT]
@@ -26,7 +28,7 @@ The structure of the ModuleTools module is meticulously designed according to Po
2628
Install-Module -Name ModuleTools
2729
```
2830

29-
> Note: ModuleTolls is still in early development phase and lot of changes are expected. Please read through [ChangeLog](/CHANGELOG.md) for all updates.
31+
> Note: ModuleTolls is still in early devleopment phase and lot of changes are expected. Please read through [ChangeLog](/CHANGELOG.md) for all updates.
3032
3133
## 🧵 Design
3234

@@ -60,6 +62,8 @@ Generated module is stored in dist folder, you can easily import it or publish i
6062
└──  TestModule.psm1
6163
```
6264

65+
66+
6367
### Project JSON File
6468

6569
The `project.json` file contains all the important details about your module and is used during the module build. It should comply with a specific schema. You can refer to the sample `project-sample.json` file in the `example` directory for guidance.
@@ -68,43 +72,9 @@ Run `New-MTModule` to generate the scaffolding; this will also create the `proje
6872

6973
### Src Folder
7074

71-
- Place all your functions in the `private` and `public` folders within the `src` directory.
72-
- All functions in the `public` folder are exported during the module build.
73-
- All functions in the `private` folder are accessible internally within the module but are not exposed outside the module.
74-
- Contents of the `src/resources` folder, including any subfolder, will included in the `dist` folder during the module build.
75-
76-
#### resources Folder
77-
78-
The `resources` folder within the `src` directory is intended for including any additional resources required by your module. This can include files such as:
79-
80-
- **Configuration files**: Store any JSON, XML, or other configuration files needed by your module.
81-
- **Script files**: Place any scripts that are used by your functions or modules, but are not directly part of the public or private functions.
82-
- **Documentation files**: Include any supplementary documentation that supports the usage or development of the module.
83-
- **Data files**: Store any data files that are used by your module, such as CSV or JSON files.
84-
- **Subfolder**: Include any additional folders and their content to be included with the module, such as dependant Modules, APIs, DLLs, etc... organized by a subfolder.
85-
86-
When the module is built, the contents of the `src/resources` folder will be copied directly to the `dist` folder. If the `src/resources` folder contains any subfolders, those subfolders and their contents will also be included in the `dist` folder, ensuring that all necessary files are available for the module to function correctly.
87-
88-
How the resources folder gets copied to the "OutputModuleDir" folder will depends on the "ResourceCopyMode" project setting. When missing or set to "Folder", the resources folder will be copied. When "ResourceCopyMode" is set to "Content", then only the content of the resources folder will be copied.
89-
90-
Leave `src\resources` empty if there is no need to include any additional content in the `dist` folder.
91-
92-
An example of the module build where resources were included:
93-
94-
```powershell
95-
dist
96-
└── TestModule
97-
├── TestModule.psd1
98-
├── TestModule.psm1
99-
├── config.json
100-
├── additionalScript.ps1
101-
├── helpDocumentation.md
102-
├── sampleData.csv
103-
└── subfolder
104-
├── subConfig.json
105-
├── subScript.ps1
106-
└── subData.csv
107-
```
75+
- Place all your functions in the `private` and `public` folders within the `src` directory.
76+
- All functions in the `public` folder are exported during the module build.
77+
- All functions in the `private` folder are accessible internally within the module but are not exposed outside the module.
10878

10979
### Tests Folder
11080

@@ -127,11 +97,6 @@ New-MTModule ~/Work
12797

12898
`ModuleTools` is designed so that you don't need any additional tools like `make` or `psake` to run the build commands. There's no need to maintain complex `build.ps1` files or sample `.psd1` files. Simply follow the structure outlined above, and you can run `Invoke-MTBuild` to build the module. The output will be saved in the `dist` folder, ready for distribution.
12999

130-
The Invoke-MTBuild CmdLet includes a step where the resources folder and/or it's contents are copied to the "OutputModuleDir" folder. This is controlled by the optional "ResourceCopyMode" project setting.
131-
132-
If "ResourceCopyMode" = 'Folder or if it's missing, the entire resources folder gets copied to the "OutputModuleDir" folder.
133-
If "ResourceCopyMode" = 'Content', only the content of the resources folder gets copied to the "OutputModuleDir" folder.
134-
135100
```powershell
136101
# From the Module root
137102
Invoke-MTBuild
@@ -161,15 +126,7 @@ A simple command to update the module version by modifying the values in `projec
161126

162127
## Advanced - Use it in Github Actions
163128

164-
This is not required for local module builds, if you are running github actions, use the following yaml workflow template to test, build and publish module which helps to automate the process of:
165-
166-
1. Checking out the repository code.
167-
1. Installing the `ModuleTools` module from the PowerShell Gallery.
168-
1. Building the module.
169-
1. Running Pester tests.
170-
1. Publishing the module to a specified repository.
171-
172-
This allows for seamless and automated management of your PowerShell module, ensuring consistency and reliability in your build, test, and release processes.
129+
This is not required for local module builds, if you are running github actions, use below template to test, build and publish module with ease.
173130

174131
```yaml
175132
name: Build, Test and Publish
@@ -197,7 +154,6 @@ jobs:
197154
- name: Run Pester Tests
198155
run: Invoke-MTTest
199156
shell: pwsh
200-
201157
- name: Publish Package to Github
202158
run: |
203159
Publish-PSResource -Path ./dist/YourModule -Repository SomeRepository -ApiKey $Env:ApiKey

project.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"ProjectName": "ModuleTools",
33
"Description": "ModuleTools is a versatile, standalone PowerShell module builder. Create anything from simple to robust modules with ease. Built for CICD and Automation.",
4-
"Version": "0.0.10",
5-
"ResourceCopyMode": "Folder",
4+
"Version": "0.0.9",
65
"Manifest": {
76
"Author": "Manjunath Beli",
87
"PowerShellHostVersion": "7.4",
Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
function Copy-ProjectResource {
22
$data = Get-MTProjectInfo
33
$resFolder = [System.IO.Path]::Join($data.ProjectRoot, 'src', 'resources')
4+
45
if (Test-Path $resFolder) {
5-
if ($data.ResourceCopyMode -eq 'Content') {
6-
# Copy the resources folder content to the OutputModuleDir
7-
$items = Get-ChildItem -Path $resFolder -ErrorAction SilentlyContinue
8-
if ($items) {
9-
Write-Verbose 'Files found in resource folder, copying resource folder content'
10-
foreach ($item in $items) {
11-
Copy-Item -Path $item.FullName -Destination ($data.OutputModuleDir) -Recurse -Force -ErrorAction Stop
12-
}
13-
}
14-
} else {
15-
# Copy the resources folder to the OutputModuleDir
16-
if (Get-ChildItem $resFolder -ErrorAction SilentlyContinue) {
17-
Write-Verbose 'Files found in resource folder, Copying resource folder'
18-
Copy-Item -Path $resFolder -Destination ($data.OutputModuleDir) -Recurse -Force -ErrorAction Stop
19-
}
6+
if (Get-ChildItem $resFolder -ErrorAction SilentlyContinue) {
7+
Write-Verbose 'Files found in resource folder, Copying resource folder content'
8+
Copy-Item -Path $resFolder -Destination ($data.OutputModuleDir) -Recurse -Force -ErrorAction Stop
209
}
2110
}
22-
}
11+
}

src/resources/ProjectTemplate.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"ProjectName": "",
33
"Description": "",
44
"Version": "",
5-
"ResourceCopyMode": "",
65
"Manifest": {
76
"Author": "",
87
"PowerShellHostVersion": "",

src/resources/Schema-Build.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
"Version": {
1313
"type": "string"
1414
},
15-
"ResourceCopyMode": {
16-
"type": "string"
17-
},
1815
"Manifest": {
1916
"type": "object",
2017
"properties": {

0 commit comments

Comments
 (0)