stackforge-cli 0.1.2__py3-none-any.whl → 0.1.4__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.
@@ -1,111 +1,126 @@
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
+
6
+ def generate_sln(base: Path, project: str):
7
+ layers = ["API", "Application", "Domain", "Infrastructure", "Persistence"]
8
+ configurations = ["Debug|Any CPU", "Release|Any CPU"]
9
+
10
+ project_entries = ""
11
+ project_configs = ""
12
+ for layer in layers:
13
+ guid = "{" + str(uuid.uuid4()).upper() + "}"
14
+ project_entries += f"""Project("{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}") = "{layer}", "{layer}\\{layer}.csproj", "{guid}"
15
+ EndProject
16
+ """
17
+ for config in configurations:
18
+ project_configs += f"\t\t{guid}.{config}.ActiveCfg = {config}\n"
19
+ project_configs += f"\t\t{guid}.{config}.Build.0 = {config}\n"
20
+
21
+ solution_configs = "".join(f"\t\t{config} = {config}\n" for config in configurations)
22
+
23
+ # Without the Global section, dotnet build/restore on the .sln finds no projects to build.
24
+ content = f"""
25
+ Microsoft Visual Studio Solution File, Format Version 12.00
26
+ # Visual Studio Version 17
27
+ {project_entries}Global
28
+ \tGlobalSection(SolutionConfigurationPlatforms) = preSolution
29
+ {solution_configs}\tEndGlobalSection
30
+ \tGlobalSection(ProjectConfigurationPlatforms) = postSolution
31
+ {project_configs}\tEndGlobalSection
32
+ EndGlobal
33
+ """
34
+
35
+ file_path = base / f"{project}.sln"
36
+ file_path.write_text(content)
37
+ ui.file_created(f"{project}.sln")
38
+
39
+
40
+ def generate_gitignore(base: Path):
41
+ content = """# Build results
42
+ bin/
43
+ obj/
44
+ out/
45
+
46
+ # Environment
47
+ .env
48
+
49
+ # VS / Rider
50
+ .vs/
51
+ .idea/
52
+ *.user
53
+
54
+ # Logs
55
+ *.log
56
+ """
57
+
58
+ file_path = base / ".gitignore"
59
+ file_path.write_text(content)
60
+ ui.file_created(".gitignore")
61
+
62
+
63
+ def generate_github_workflow(base: Path):
64
+ workflow_dir = base / ".github" / "workflows"
65
+ workflow_dir.mkdir(parents=True, exist_ok=True)
66
+
67
+ content = """name: Sync Environment Branches
68
+
69
+ on:
70
+ push:
71
+ branches:
72
+ - main
73
+
74
+ permissions:
75
+ contents: write
76
+
77
+ jobs:
78
+ sync-branches:
79
+ runs-on: ubuntu-latest
80
+ steps:
81
+ - uses: actions/checkout@v4
82
+ with:
83
+ fetch-depth: 0
84
+
85
+ - name: Create staging branch if missing
86
+ run: |
87
+ if ! git ls-remote --exit-code origin refs/heads/staging; then
88
+ git push origin HEAD:refs/heads/staging
89
+ fi
90
+
91
+ - name: Create development branch if missing
92
+ run: |
93
+ if ! git ls-remote --exit-code origin refs/heads/development; then
94
+ git push origin HEAD:refs/heads/development
95
+ fi
96
+ """
97
+ file_path = workflow_dir / "sync-branches.yml"
98
+ file_path.write_text(content.lstrip())
99
+ ui.file_created(".github/workflows/sync-branches.yml")
100
+
101
+
102
+ def git_init(base: Path, project: str):
103
+ try:
104
+ subprocess.run(["git", "init", "-b", "main"], cwd=base, check=True, capture_output=True)
105
+ ui.file_created("git init (main)")
106
+
107
+ subprocess.run(["git", "add", "."], cwd=base, check=True, capture_output=True)
108
+ ui.file_created("git add .")
109
+
110
+ subprocess.run(
111
+ ["git", "commit", "-m", f"initial: scaffold {project} with stackforge"],
112
+ cwd=base,
113
+ check=True,
114
+ capture_output=True
115
+ )
116
+ ui.file_created("initial commit")
117
+
118
+ subprocess.run(["git", "branch", "staging"], cwd=base, check=True, capture_output=True)
119
+ subprocess.run(["git", "branch", "development"], cwd=base, check=True, capture_output=True)
120
+ ui.file_created("branches: main, staging, development")
121
+
122
+ except subprocess.CalledProcessError as e:
123
+ ui.error(f"Git error: {e}")
124
+ except FileNotFoundError:
125
+ ui.error("Git not found. Make sure Git is installed and in your PATH.")
126
+