stackforge-cli 0.1.3__py3-none-any.whl → 0.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. stackforge/engines/dotnet/__init__.py +7 -7
  2. stackforge/engines/dotnet/api_generator.py +39 -313
  3. stackforge/engines/dotnet/config_generator.py +20 -77
  4. stackforge/engines/dotnet/csproj_generator.py +82 -82
  5. stackforge/engines/dotnet/docker_generator.py +15 -64
  6. stackforge/engines/dotnet/git_generator.py +77 -111
  7. stackforge/engines/dotnet/layers_generator.py +103 -544
  8. stackforge/engines/dotnet/program_generator.py +21 -195
  9. stackforge/engines/dotnet/scaffolder.py +74 -74
  10. stackforge/project_name.py +34 -34
  11. stackforge/scaffold.py +90 -90
  12. stackforge/templates/dotnet/API/Configurations/Swagger/ApiRoles.cs.tmpl +9 -0
  13. stackforge/templates/dotnet/API/ConfigureServices.cs.tmpl +120 -0
  14. stackforge/templates/dotnet/API/Controllers/BaseApiController.cs.tmpl +24 -0
  15. stackforge/templates/dotnet/API/Controllers/Main/AccountController.cs.tmpl +68 -0
  16. stackforge/templates/dotnet/API/DTOs/AccountDTOs.cs.tmpl +23 -0
  17. stackforge/templates/dotnet/API/Interface/IJwtService.cs.tmpl +7 -0
  18. stackforge/templates/dotnet/API/Options/JwtOptions.cs.tmpl +10 -0
  19. stackforge/templates/dotnet/API/Program.cs.tmpl +45 -0
  20. stackforge/templates/dotnet/API/Properties/launchSettings.json.tmpl +31 -0
  21. stackforge/templates/dotnet/API/Services/JwtService.cs.tmpl +41 -0
  22. stackforge/templates/dotnet/API/Swagger/EnumMemberSchemaFilter.cs.tmpl +25 -0
  23. stackforge/templates/dotnet/API/appsettings.Development.json.tmpl +17 -0
  24. stackforge/templates/dotnet/API/appsettings.json.tmpl +18 -0
  25. stackforge/templates/dotnet/Application/Common/Behaviors/ValidationBehavior.cs.tmpl +29 -0
  26. stackforge/templates/dotnet/Application/Common/Constants/ErrorMessages.cs.tmpl +10 -0
  27. stackforge/templates/dotnet/Application/Common/Exceptions/AppExceptions.cs.tmpl +12 -0
  28. stackforge/templates/dotnet/Application/Common/Exceptions/NotFoundException.cs.tmpl +10 -0
  29. stackforge/templates/dotnet/Application/Common/Models/ApiResponse.cs.tmpl +15 -0
  30. stackforge/templates/dotnet/Application/Common/Models/PagedList.cs.tmpl +30 -0
  31. stackforge/templates/dotnet/Application/Common/Models/PagedResponse.cs.tmpl +13 -0
  32. stackforge/templates/dotnet/Application/Common/Models/PaginatedResult.cs.tmpl +13 -0
  33. stackforge/templates/dotnet/Application/Common/Models/PagingParams.cs.tmpl +8 -0
  34. stackforge/templates/dotnet/Application/Common/Models/Result.cs.tmpl +30 -0
  35. stackforge/templates/dotnet/Application/Common/Models/Serialization/IsoDateTime.cs.tmpl +14 -0
  36. stackforge/templates/dotnet/Application/ConfigureServices.cs.tmpl +22 -0
  37. stackforge/templates/dotnet/Dockerfile.tmpl +8 -0
  38. stackforge/templates/dotnet/Domain/Common/BaseEntity.cs.tmpl +9 -0
  39. stackforge/templates/dotnet/Domain/Common/EnumMemberExtensions.cs.tmpl +16 -0
  40. stackforge/templates/dotnet/Domain/Entities/Identity/Role.cs.tmpl +9 -0
  41. stackforge/templates/dotnet/Domain/Entities/Identity/User.cs.tmpl +13 -0
  42. stackforge/templates/dotnet/Domain/Entities/Identity/UserRole.cs.tmpl +10 -0
  43. stackforge/templates/dotnet/Domain/GlobalUsings.cs.tmpl +2 -0
  44. stackforge/templates/dotnet/Infrastructure/ConfigureServices.cs.tmpl +14 -0
  45. stackforge/templates/dotnet/Persistence/Configurations/UserRoleConfiguration.cs.tmpl +24 -0
  46. stackforge/templates/dotnet/Persistence/ConfigureServices.cs.tmpl +18 -0
  47. stackforge/templates/dotnet/Persistence/DataContext.cs.tmpl +36 -0
  48. stackforge/templates/dotnet/Persistence/Seeders/RoleSeeder.cs.tmpl +19 -0
  49. stackforge/templates/dotnet/Persistence/Seeders/UserSeeder.cs.tmpl +28 -0
  50. stackforge/templates/dotnet/docker-compose.yml.tmpl +36 -0
  51. stackforge/templates/dotnet/dot_env.tmpl +10 -0
  52. stackforge/templates/dotnet/dot_github/workflows/sync-branches.yml.tmpl +29 -0
  53. stackforge/templates/dotnet/dot_gitignore.tmpl +15 -0
  54. stackforge/templating.py +39 -0
  55. stackforge/ui.py +72 -72
  56. stackforge/version.py +48 -48
  57. {stackforge_cli-0.1.3.dist-info → stackforge_cli-0.1.5.dist-info}/METADATA +109 -107
  58. stackforge_cli-0.1.5.dist-info/RECORD +62 -0
  59. {stackforge_cli-0.1.3.dist-info → stackforge_cli-0.1.5.dist-info}/WHEEL +1 -1
  60. stackforge_cli-0.1.3.dist-info/RECORD +0 -19
  61. {stackforge_cli-0.1.3.dist-info → stackforge_cli-0.1.5.dist-info}/entry_points.txt +0 -0
  62. {stackforge_cli-0.1.3.dist-info → stackforge_cli-0.1.5.dist-info}/top_level.txt +0 -0
@@ -1,64 +1,15 @@
1
- from pathlib import Path
2
- from stackforge import ui
3
-
4
-
5
- def generate_dockerfile(base: Path):
6
- content = """FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
7
- WORKDIR /app
8
-
9
- COPY . .
10
-
11
- RUN dotnet publish API/API.csproj -c Release -o out
12
-
13
- ENTRYPOINT ["dotnet", "out/API.dll"]
14
- """
15
-
16
- file_path = base / "Dockerfile"
17
- file_path.write_text(content)
18
- ui.file_created("Dockerfile")
19
-
20
-
21
- def generate_docker_compose(base: Path, project: str):
22
- project_lower = project.lower()
23
-
24
- content = f"""services:
25
- api:
26
- build: .
27
- container_name: {project_lower}_api
28
- ports:
29
- - "5000:8080"
30
- environment:
31
- - ASPNETCORE_ENVIRONMENT=Development
32
- - ConnectionStrings__DefaultConnection=Host=db;Port=5432;Database={project_lower}_db;Username=postgres;Password=postgres
33
- - Jwt__Issuer=http://localhost:5000
34
- - Jwt__Audience=http://localhost:5000
35
- - Jwt__SecretKey=your-super-secret-key-change-this-in-production
36
- - Jwt__ExpiryMinutes=60
37
- depends_on:
38
- db:
39
- condition: service_healthy
40
-
41
- db:
42
- image: postgres:latest
43
- container_name: {project_lower}_db
44
- environment:
45
- POSTGRES_DB: {project_lower}_db
46
- POSTGRES_USER: postgres
47
- POSTGRES_PASSWORD: postgres
48
- ports:
49
- - "5432:5432"
50
- volumes:
51
- - {project_lower}_pgdata:/var/lib/postgresql
52
- healthcheck:
53
- test: ["CMD-SHELL", "pg_isready -U postgres"]
54
- interval: 5s
55
- timeout: 5s
56
- retries: 5
57
-
58
- volumes:
59
- {project_lower}_pgdata:
60
- """
61
-
62
- file_path = base / "docker-compose.yml"
63
- file_path.write_text(content)
64
- ui.file_created("docker-compose.yml")
1
+ from pathlib import Path
2
+ from stackforge import ui
3
+ from stackforge.templating import render_file
4
+
5
+ ENGINE = "dotnet"
6
+
7
+
8
+ def generate_dockerfile(base: Path, project: str = ""):
9
+ render_file(ENGINE, base, "Dockerfile", project)
10
+ ui.file_created("Dockerfile")
11
+
12
+
13
+ def generate_docker_compose(base: Path, project: str):
14
+ render_file(ENGINE, base, "docker-compose.yml", project)
15
+ ui.file_created("docker-compose.yml")
@@ -1,111 +1,77 @@
1
- import subprocess
2
- from pathlib import Path
3
- from stackforge import ui
4
-
5
- def generate_sln(base: Path, project: str):
6
- layers = ["API", "Application", "Domain", "Infrastructure", "Persistence"]
7
-
8
- project_entries = ""
9
- for layer in layers:
10
- guid = str(__import__('uuid').uuid4()).upper()
11
- project_entries += f"""Project("{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}") = "{layer}", "{layer}\\{layer}.csproj", "{{{guid}}}"
12
- EndProject
13
- """
14
-
15
- content = f"""
16
- Microsoft Visual Studio Solution File, Format Version 12.00
17
- # Visual Studio Version 17
18
- {project_entries}"""
19
-
20
- file_path = base / f"{project}.sln"
21
- file_path.write_text(content)
22
- ui.file_created(f"{project}.sln")
23
-
24
-
25
- def generate_gitignore(base: Path):
26
- content = """# Build results
27
- bin/
28
- obj/
29
- out/
30
-
31
- # Environment
32
- .env
33
-
34
- # VS / Rider
35
- .vs/
36
- .idea/
37
- *.user
38
-
39
- # Logs
40
- *.log
41
- """
42
-
43
- file_path = base / ".gitignore"
44
- file_path.write_text(content)
45
- ui.file_created(".gitignore")
46
-
47
-
48
- def generate_github_workflow(base: Path):
49
- workflow_dir = base / ".github" / "workflows"
50
- workflow_dir.mkdir(parents=True, exist_ok=True)
51
-
52
- content = """name: Sync Environment Branches
53
-
54
- on:
55
- push:
56
- branches:
57
- - main
58
-
59
- permissions:
60
- contents: write
61
-
62
- jobs:
63
- sync-branches:
64
- runs-on: ubuntu-latest
65
- steps:
66
- - uses: actions/checkout@v4
67
- with:
68
- fetch-depth: 0
69
-
70
- - name: Create staging branch if missing
71
- run: |
72
- if ! git ls-remote --exit-code origin refs/heads/staging; then
73
- git push origin HEAD:refs/heads/staging
74
- fi
75
-
76
- - name: Create development branch if missing
77
- run: |
78
- if ! git ls-remote --exit-code origin refs/heads/development; then
79
- git push origin HEAD:refs/heads/development
80
- fi
81
- """
82
- file_path = workflow_dir / "sync-branches.yml"
83
- file_path.write_text(content.lstrip())
84
- ui.file_created(".github/workflows/sync-branches.yml")
85
-
86
-
87
- def git_init(base: Path, project: str):
88
- try:
89
- subprocess.run(["git", "init", "-b", "main"], cwd=base, check=True, capture_output=True)
90
- ui.file_created("git init (main)")
91
-
92
- subprocess.run(["git", "add", "."], cwd=base, check=True, capture_output=True)
93
- ui.file_created("git add .")
94
-
95
- subprocess.run(
96
- ["git", "commit", "-m", f"initial: scaffold {project} with stackforge"],
97
- cwd=base,
98
- check=True,
99
- capture_output=True
100
- )
101
- ui.file_created("initial commit")
102
-
103
- subprocess.run(["git", "branch", "staging"], cwd=base, check=True, capture_output=True)
104
- subprocess.run(["git", "branch", "development"], cwd=base, check=True, capture_output=True)
105
- ui.file_created("branches: main, staging, development")
106
-
107
- except subprocess.CalledProcessError as e:
108
- ui.error(f"Git error: {e}")
109
- except FileNotFoundError:
110
- ui.error("Git not found. Make sure Git is installed and in your PATH.")
111
-
1
+ import uuid
2
+ import subprocess
3
+ from pathlib import Path
4
+ from stackforge import ui
5
+ from stackforge.templating import render_file
6
+
7
+ ENGINE = "dotnet"
8
+
9
+ def generate_sln(base: Path, project: str):
10
+ layers = ["API", "Application", "Domain", "Infrastructure", "Persistence"]
11
+ configurations = ["Debug|Any CPU", "Release|Any CPU"]
12
+
13
+ project_entries = ""
14
+ project_configs = ""
15
+ for layer in layers:
16
+ guid = "{" + str(uuid.uuid4()).upper() + "}"
17
+ project_entries += f"""Project("{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}") = "{layer}", "{layer}\\{layer}.csproj", "{guid}"
18
+ EndProject
19
+ """
20
+ for config in configurations:
21
+ project_configs += f"\t\t{guid}.{config}.ActiveCfg = {config}\n"
22
+ project_configs += f"\t\t{guid}.{config}.Build.0 = {config}\n"
23
+
24
+ solution_configs = "".join(f"\t\t{config} = {config}\n" for config in configurations)
25
+
26
+ # Without the Global section, dotnet build/restore on the .sln finds no projects to build.
27
+ content = f"""
28
+ Microsoft Visual Studio Solution File, Format Version 12.00
29
+ # Visual Studio Version 17
30
+ {project_entries}Global
31
+ \tGlobalSection(SolutionConfigurationPlatforms) = preSolution
32
+ {solution_configs}\tEndGlobalSection
33
+ \tGlobalSection(ProjectConfigurationPlatforms) = postSolution
34
+ {project_configs}\tEndGlobalSection
35
+ EndGlobal
36
+ """
37
+
38
+ file_path = base / f"{project}.sln"
39
+ file_path.write_text(content)
40
+ ui.file_created(f"{project}.sln")
41
+
42
+
43
+ def generate_gitignore(base: Path, project: str = ""):
44
+ render_file(ENGINE, base, ".gitignore", project)
45
+ ui.file_created(".gitignore")
46
+
47
+
48
+ def generate_github_workflow(base: Path, project: str = ""):
49
+ render_file(ENGINE, base, ".github/workflows/sync-branches.yml", project)
50
+ ui.file_created(".github/workflows/sync-branches.yml")
51
+
52
+
53
+ def git_init(base: Path, project: str):
54
+ try:
55
+ subprocess.run(["git", "init", "-b", "main"], cwd=base, check=True, capture_output=True)
56
+ ui.file_created("git init (main)")
57
+
58
+ subprocess.run(["git", "add", "."], cwd=base, check=True, capture_output=True)
59
+ ui.file_created("git add .")
60
+
61
+ subprocess.run(
62
+ ["git", "commit", "-m", f"initial: scaffold {project} with stackforge"],
63
+ cwd=base,
64
+ check=True,
65
+ capture_output=True
66
+ )
67
+ ui.file_created("initial commit")
68
+
69
+ subprocess.run(["git", "branch", "staging"], cwd=base, check=True, capture_output=True)
70
+ subprocess.run(["git", "branch", "development"], cwd=base, check=True, capture_output=True)
71
+ ui.file_created("branches: main, staging, development")
72
+
73
+ except subprocess.CalledProcessError as e:
74
+ ui.error(f"Git error: {e}")
75
+ except FileNotFoundError:
76
+ ui.error("Git not found. Make sure Git is installed and in your PATH.")
77
+