Skip to content

Commit fee7865

Browse files
committed
updated the pipelines
1 parent 9cecf7b commit fee7865

File tree

4 files changed

+174
-3
lines changed

4 files changed

+174
-3
lines changed

.github/workflows/template-publish.yml

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,20 @@ jobs:
7474
- name: Copy README template
7575
shell: pwsh
7676
run: |
77-
# Copy the README template if it exists
77+
# Ensure README is properly set up for NuGet package
78+
Write-Host "Setting up README for NuGet package..."
79+
80+
# Check if README template exists in template-src
7881
if (Test-Path "./template-src/README.template.md") {
82+
# Copy as main README.md in the template output root
7983
Copy-Item -Path "./template-src/README.template.md" -Destination "./template-output/README.md"
80-
}
84+
85+
# Create docs directory for NuGet's readme reference
86+
New-Item -Path "./template-output/docs" -ItemType Directory -Force
87+
Copy-Item -Path "./template-src/README.template.md" -Destination "./template-output/docs/README.md"
88+
89+
Write-Host "✅ README files set up successfully"
90+
}
8191
8292
- name: Copy and update .nuspec file
8393
shell: pwsh
@@ -184,6 +194,56 @@ jobs:
184194
# List files to verify creation
185195
dir
186196
197+
- name: Test template package without Angular
198+
run: |
199+
mkdir test-project-no-angular
200+
cd test-project-no-angular
201+
202+
# Create project from template without Angular
203+
dotnet new cleanarch --organization TestCompany --projectName TestProjectNoAngular --includeAngular false
204+
205+
# Verify that frontend directory is not created
206+
if (Test-Path "./frontend") {
207+
Write-Error "Frontend directory should not exist when includeAngular is false"
208+
exit 1
209+
}
210+
211+
# List files to verify creation
212+
dir
213+
214+
- name: Test template package with default folder naming
215+
shell: pwsh
216+
run: |
217+
# Test with organization - should create folder YourCompany.TestProject
218+
dotnet new cleanarch --organization YourCompany --projectName TestProject
219+
220+
if (Test-Path "YourCompany.TestProject") {
221+
Write-Host "✅ YourCompany.TestProject folder created successfully"
222+
} else {
223+
Write-Error "❌ YourCompany.TestProject folder not created"
224+
exit 1
225+
}
226+
227+
# Test without organization - should create folder TestProjectNoOrg
228+
dotnet new cleanarch --projectName TestProjectNoOrg
229+
230+
if (Test-Path "TestProjectNoOrg") {
231+
Write-Host "✅ TestProjectNoOrg folder created successfully"
232+
} else {
233+
Write-Error "❌ TestProjectNoOrg folder not created"
234+
exit 1
235+
}
236+
237+
# Test with explicit output folder
238+
dotnet new cleanarch --organization YourCompany --projectName TestProject -o CustomFolder
239+
240+
if (Test-Path "CustomFolder") {
241+
Write-Host "✅ CustomFolder created successfully"
242+
} else {
243+
Write-Error "❌ CustomFolder not created"
244+
exit 1
245+
}
246+
187247
- name: Upload package artifact
188248
uses: actions/upload-artifact@v4
189249
with:

template-src/CleanArchitecture.FullStack.Template.nuspec

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,13 @@
1616
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1717
<copyright>Copyright © Nitin Singh 2024</copyright>
1818
<summary>A full-stack template using Clean Architecture principles with .NET 9 API backend and Angular 19 frontend, containerized with Docker.</summary>
19+
<readme>docs\README.md</readme>
1920
</metadata>
21+
<files>
22+
<!-- Include all template content files but exclude binaries and temp files -->
23+
<file src="**\*" target="content" exclude="**\bin\**;**\obj\**;**\.git\**;**\.vs\**;**\.vscode\**;**\node_modules\**;**\.angular\**;**\docs\**" />
24+
25+
<!-- Explicitly include the README for NuGet package display -->
26+
<file src="docs\README.md" target="docs\" />
27+
</files>
2028
</package>

template-src/README.template.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,27 @@ This template provides a starting point for creating a Clean Architecture soluti
2121
2. **Create a new project using the template:**
2222

2323
```bash
24+
# Create with organization - output folder will be "YourCompany.MyApp"
2425
dotnet new cleanarch --organization YourCompany --projectName MyApp
26+
27+
# Create without organization - output folder will be just "MyApp"
28+
dotnet new cleanarch --projectName MyApp
29+
30+
# Create in a specific folder (overrides default folder behavior)
31+
dotnet new cleanarch --organization YourCompany --projectName MyApp -o CustomFolder
2532
```
2633

2734
3. **Navigate to the project directory:**
2835

2936
```bash
37+
# If created with organization
38+
cd YourCompany.MyApp
39+
40+
# If created without organization
3041
cd MyApp
42+
43+
# If created with custom output folder
44+
cd CustomFolder
3145
```
3246

3347
4. **Build and run the project:**
@@ -36,10 +50,64 @@ This template provides a starting point for creating a Clean Architecture soluti
3650
docker-compose up
3751
```
3852

53+
## Command Examples for Different Scenarios
54+
55+
### Basic Usage
56+
57+
```bash
58+
# Full-stack application with organization name
59+
dotnet new cleanarch --organization Acme --projectName ECommerce
60+
61+
# Full-stack application without organization name
62+
dotnet new cleanarch --projectName ECommerce
63+
```
64+
65+
### Backend-only Application
66+
67+
```bash
68+
# Create backend-only application (exclude Angular)
69+
dotnet new cleanarch --organization Acme --projectName ApiService --includeAngular false
70+
71+
# Backend-only application without organization name
72+
dotnet new cleanarch --projectName ApiService --includeAngular false
73+
```
74+
75+
### Custom Output Location
76+
77+
```bash
78+
# Specify a custom output folder
79+
dotnet new cleanarch --organization Acme --projectName ECommerce -o ./projects/ecommerce-app
80+
81+
# Specify output folder without organization name
82+
dotnet new cleanarch --projectName ECommerce -o ./projects/ecommerce-app
83+
```
84+
85+
### Combining Options
86+
87+
```bash
88+
# Backend-only application with custom output folder
89+
dotnet new cleanarch --organization Acme --projectName ApiService --includeAngular false -o ./apis/service
90+
91+
# Full options example
92+
dotnet new cleanarch --organization Acme --projectName ECommerce --includeAngular true -o ./projects/ecommerce-app
93+
```
94+
3995
## Template Parameters
4096

4197
- `--organization`: Optional organization or company name to be used in namespaces. If specified, namespaces will be formatted as `YourCompany.MyApp.Feature`. If not specified, namespaces will be formatted as `MyApp.Feature`.
4298
- `--projectName`: The name of the project. Default is `MyApp`.
99+
- `--includeAngular`: Boolean flag to indicate whether to include the Angular frontend project. Default is `true`.
100+
- `-o|--output`: Optional parameter to specify a custom output folder. If not specified, the output folder will be `<organization>.<projectName>` if organization is provided, or just `<projectName>` if it isn't.
101+
102+
## Output Folder Naming
103+
104+
The template uses the following rules to determine the output folder name:
105+
106+
| Command Parameters | Output Folder |
107+
| ------------------ | ------------- |
108+
| `--organization YourCompany --projectName MyApp` | `YourCompany.MyApp` |
109+
| `--projectName MyApp` (no organization) | `MyApp` |
110+
| `--organization YourCompany --projectName MyApp -o CustomFolder` | `CustomFolder` |
43111

44112
## Directory Structure
45113

template-src/template.json

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,34 @@
2626
"defaultValue": "MyApp",
2727
"replaces": "ProjectNamePlaceholder"
2828
},
29+
"includeAngular": {
30+
"type": "parameter",
31+
"datatype": "bool",
32+
"description": "If specified, includes the Angular frontend project.",
33+
"defaultValue": "true"
34+
},
2935
"skipOrgPrefix": {
3036
"type": "computed",
3137
"value": "(organization == \"\")"
38+
},
39+
"defaultFolderName": {
40+
"type": "generated",
41+
"generator": "coalesce",
42+
"parameters": {
43+
"sourceVariableName": "organization",
44+
"fallbackVariableName": "projectName",
45+
"operations": [
46+
{
47+
"type": "conditional",
48+
"configuration": {
49+
"condition": "(organization != \"\")",
50+
"value": "$(organization).$(projectName)",
51+
"else": "$(projectName)"
52+
}
53+
}
54+
]
55+
},
56+
"replaces": "defaultFolderName"
3257
}
3358
},
3459
"forms": {
@@ -39,5 +64,15 @@
3964
"to": "$1.$2"
4065
}
4166
}
42-
}
67+
},
68+
"sources": [
69+
{
70+
"modifiers": [
71+
{
72+
"condition": "(!includeAngular)",
73+
"exclude": [ "frontend/**/*" ]
74+
}
75+
]
76+
}
77+
]
4378
}

0 commit comments

Comments
 (0)