stackforge-cli 0.1.1__py3-none-any.whl → 0.1.2__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.
@@ -3,6 +3,6 @@ from .csproj_generator import generate_csproj
3
3
  from .program_generator import generate_configure_services, generate_program_cs
4
4
  from .docker_generator import generate_dockerfile, generate_docker_compose
5
5
  from .config_generator import generate_env, generate_appsettings, generate_appsettings_development
6
- from .git_generator import generate_gitignore, git_init
6
+ from .git_generator import generate_gitignore, generate_github_workflow, git_init
7
7
  from .api_generator import generate_api_structure
8
8
  from .layers_generator import generate_domain_layer, generate_application_layer, generate_infrastructure_layer, generate_persistence_layer
@@ -1,4 +1,5 @@
1
1
  from pathlib import Path
2
+ from stackforge import ui
2
3
 
3
4
 
4
5
  def generate_api_structure(base: Path, project: str):
@@ -28,7 +29,7 @@ def generate_api_structure(base: Path, project: str):
28
29
  _generate_login_dto(base, project)
29
30
  _generate_account_controller(base, project)
30
31
 
31
- print(" [+] API/ structure and files")
32
+ ui.file_created("API/ structure and files")
32
33
 
33
34
 
34
35
  def _generate_base_controller(base: Path, project: str):
@@ -1,4 +1,5 @@
1
1
  from pathlib import Path
2
+ from stackforge import ui
2
3
 
3
4
 
4
5
  def generate_env(base: Path, project: str):
@@ -18,7 +19,7 @@ JWT_EXPIRY_MINUTES=60
18
19
 
19
20
  file_path = base / ".env"
20
21
  file_path.write_text(content)
21
- print(" [+] .env")
22
+ ui.file_created(".env")
22
23
 
23
24
 
24
25
  def generate_appsettings(base: Path, project: str):
@@ -46,7 +47,7 @@ def generate_appsettings(base: Path, project: str):
46
47
 
47
48
  file_path = base / "API" / "appsettings.json"
48
49
  file_path.write_text(content)
49
- print(" [+] API/appsettings.json")
50
+ ui.file_created("API/appsettings.json")
50
51
 
51
52
 
52
53
  def generate_appsettings_development(base: Path, project: str):
@@ -73,4 +74,4 @@ def generate_appsettings_development(base: Path, project: str):
73
74
 
74
75
  file_path = base / "API" / "appsettings.Development.json"
75
76
  file_path.write_text(content)
76
- print(" [+] API/appsettings.Development.json")
77
+ ui.file_created("API/appsettings.Development.json")
@@ -1,4 +1,5 @@
1
1
  from pathlib import Path
2
+ from stackforge import ui
2
3
 
3
4
 
4
5
  LAYER_CONFIGS = {
@@ -79,4 +80,4 @@ def generate_csproj(layer: str, base: Path):
79
80
 
80
81
  csproj_path = base / layer / f"{layer}.csproj"
81
82
  csproj_path.write_text(content.strip())
82
- print(f" [+] {layer}/{layer}.csproj")
83
+ ui.file_created(f"{layer}/{layer}.csproj")
@@ -1,4 +1,5 @@
1
1
  from pathlib import Path
2
+ from stackforge import ui
2
3
 
3
4
 
4
5
  def generate_dockerfile(base: Path):
@@ -14,7 +15,7 @@ ENTRYPOINT ["dotnet", "out/API.dll"]
14
15
 
15
16
  file_path = base / "Dockerfile"
16
17
  file_path.write_text(content)
17
- print(" [+] Dockerfile")
18
+ ui.file_created("Dockerfile")
18
19
 
19
20
 
20
21
  def generate_docker_compose(base: Path, project: str):
@@ -60,4 +61,4 @@ volumes:
60
61
 
61
62
  file_path = base / "docker-compose.yml"
62
63
  file_path.write_text(content)
63
- print(" [+] docker-compose.yml")
64
+ ui.file_created("docker-compose.yml")
@@ -1,5 +1,6 @@
1
1
  import subprocess
2
2
  from pathlib import Path
3
+ from stackforge import ui
3
4
 
4
5
  def generate_sln(base: Path, project: str):
5
6
  layers = ["API", "Application", "Domain", "Infrastructure", "Persistence"]
@@ -18,7 +19,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
18
19
 
19
20
  file_path = base / f"{project}.sln"
20
21
  file_path.write_text(content)
21
- print(f" [+] {project}.sln")
22
+ ui.file_created(f"{project}.sln")
22
23
 
23
24
 
24
25
  def generate_gitignore(base: Path):
@@ -41,16 +42,55 @@ out/
41
42
 
42
43
  file_path = base / ".gitignore"
43
44
  file_path.write_text(content)
44
- print(" [+] .gitignore")
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")
45
85
 
46
86
 
47
87
  def git_init(base: Path, project: str):
48
88
  try:
49
- subprocess.run(["git", "init"], cwd=base, check=True, capture_output=True)
50
- print(" [+] git init")
89
+ subprocess.run(["git", "init", "-b", "main"], cwd=base, check=True, capture_output=True)
90
+ ui.file_created("git init (main)")
51
91
 
52
92
  subprocess.run(["git", "add", "."], cwd=base, check=True, capture_output=True)
53
- print(" [+] git add .")
93
+ ui.file_created("git add .")
54
94
 
55
95
  subprocess.run(
56
96
  ["git", "commit", "-m", f"initial: scaffold {project} with stackforge"],
@@ -58,10 +98,14 @@ def git_init(base: Path, project: str):
58
98
  check=True,
59
99
  capture_output=True
60
100
  )
61
- print(" [+] initial commit")
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")
62
106
 
63
107
  except subprocess.CalledProcessError as e:
64
- print(f" [!] Git error: {e}")
108
+ ui.error(f"Git error: {e}")
65
109
  except FileNotFoundError:
66
- print(" [!] Git not found. Make sure Git is installed and in your PATH.")
110
+ ui.error("Git not found. Make sure Git is installed and in your PATH.")
67
111
 
@@ -1,4 +1,5 @@
1
1
  from pathlib import Path
2
+ from stackforge import ui
2
3
 
3
4
 
4
5
  def generate_application_layer(base: Path, project: str):
@@ -27,7 +28,7 @@ def generate_application_layer(base: Path, project: str):
27
28
  _gen_paged_response(base, project)
28
29
  _gen_iso_datetime(base, project)
29
30
 
30
- print(" [+] Application/ structure and files")
31
+ ui.file_created("Application/ structure and files")
31
32
 
32
33
 
33
34
  def generate_domain_layer(base: Path, project: str):
@@ -47,7 +48,7 @@ def generate_domain_layer(base: Path, project: str):
47
48
  _gen_user_role(base, project)
48
49
  _gen_global_usings(base, project)
49
50
 
50
- print(" [+] Domain/ structure and files")
51
+ ui.file_created("Domain/ structure and files")
51
52
 
52
53
 
53
54
  def generate_infrastructure_layer(base: Path, project: str):
@@ -60,7 +61,7 @@ def generate_infrastructure_layer(base: Path, project: str):
60
61
  for folder in folders:
61
62
  (base / folder).mkdir(parents=True, exist_ok=True)
62
63
 
63
- print(" [+] Infrastructure/ structure and files")
64
+ ui.file_created("Infrastructure/ structure and files")
64
65
 
65
66
 
66
67
  def generate_persistence_layer(base: Path, project: str):
@@ -78,7 +79,7 @@ def generate_persistence_layer(base: Path, project: str):
78
79
  _gen_user_seeder(base, project)
79
80
  _gen_user_role_configuration(base, project)
80
81
 
81
- print(" [+] Persistence/ structure and files")
82
+ ui.file_created("Persistence/ structure and files")
82
83
 
83
84
 
84
85
  # ── Application files ──────────────────────────────────────────────────────────
@@ -1,4 +1,5 @@
1
1
  from pathlib import Path
2
+ from stackforge import ui
2
3
 
3
4
 
4
5
  def generate_configure_services(layer: str, base: Path, project: str):
@@ -67,7 +68,7 @@ namespace {project}.Persistence
67
68
 
68
69
  file_path = base / layer / "ConfigureServices.cs"
69
70
  file_path.write_text(templates[layer])
70
- print(f" [+] {layer}/ConfigureServices.cs")
71
+ ui.file_created(f"{layer}/ConfigureServices.cs")
71
72
 
72
73
 
73
74
  def generate_program_cs(base: Path, project: str):
@@ -191,4 +192,4 @@ app.Run();
191
192
 
192
193
  file_path = base / "API" / "Program.cs"
193
194
  file_path.write_text(content)
194
- print(" [+] API/Program.cs")
195
+ ui.file_created("API/Program.cs")
@@ -1,9 +1,10 @@
1
1
  from pathlib import Path
2
+ from stackforge import ui
2
3
  from .csproj_generator import generate_csproj
3
4
  from .program_generator import generate_configure_services, generate_program_cs
4
5
  from .docker_generator import generate_dockerfile, generate_docker_compose
5
6
  from .config_generator import generate_env, generate_appsettings, generate_appsettings_development
6
- from .git_generator import generate_gitignore, generate_sln, git_init
7
+ from .git_generator import generate_gitignore, generate_github_workflow, generate_sln, git_init
7
8
  from .api_generator import generate_api_structure
8
9
  from .layers_generator import (
9
10
  generate_application_layer,
@@ -21,51 +22,53 @@ def scaffold_folders(base: Path, project: str):
21
22
  "Persistence"
22
23
  ]
23
24
 
24
- print(f"\nScaffolding folders for project '{project}'...")
25
+ ui.section(f"Scaffolding '{project}'")
25
26
 
27
+ ui.step("Creating folders")
26
28
  for layer in layers:
27
29
  folder = base / layer
28
30
  folder.mkdir(parents=True, exist_ok=True)
29
- print(f" [+] {layer}")
31
+ ui.file_created(layer)
30
32
 
31
- print("\nFolder structure created.")
32
-
33
- print("\nGenerating .csproj files...")
33
+ ui.section("Generating .csproj files")
34
34
  for layer in layers:
35
35
  generate_csproj(layer, base)
36
36
 
37
- print("\nGenerating service registrations...")
37
+ ui.section("Generating service registrations")
38
38
  for layer in ["Application", "Infrastructure", "Persistence"]:
39
39
  generate_configure_services(layer, base, project)
40
40
 
41
- print("\nGenerating Program.cs...")
41
+ ui.section("Generating Program.cs")
42
42
  generate_program_cs(base, project)
43
43
 
44
- print("\nGenerating Docker files...")
44
+ ui.section("Generating Docker files")
45
45
  generate_dockerfile(base)
46
46
  generate_docker_compose(base, project)
47
47
 
48
- print("\nGenerating config files...")
48
+ ui.section("Generating config files")
49
49
  generate_env(base, project)
50
50
  generate_appsettings(base, project)
51
51
  generate_appsettings_development(base, project)
52
52
 
53
- print("\nGenerating API layer...")
53
+ ui.section("Generating API layer")
54
54
  generate_api_structure(base, project)
55
55
 
56
- print("\nGenerating layer files...")
56
+ ui.section("Generating layer files")
57
57
  generate_application_layer(base, project)
58
58
  generate_domain_layer(base, project)
59
59
  generate_infrastructure_layer(base, project)
60
60
  generate_persistence_layer(base, project)
61
61
 
62
- print("\nGenerating solution file...")
62
+ ui.section("Generating solution file")
63
63
  generate_sln(base, project)
64
64
 
65
- print("\nGenerating .gitignore...")
65
+ ui.section("Generating .gitignore")
66
66
  generate_gitignore(base)
67
67
 
68
- print("\nInitializing Git repository...")
68
+ ui.section("Generating GitHub workflow")
69
+ generate_github_workflow(base)
70
+
71
+ ui.section("Initializing Git repository")
69
72
  git_init(base, project)
70
73
 
71
- print("\nDone.")
74
+ ui.done()
@@ -0,0 +1,34 @@
1
+ import re
2
+
3
+ _CAMEL_PARTS = re.compile(r"[A-Z]?[a-z]+|[A-Z]+(?=[A-Z][a-z]|\b)|\d+")
4
+
5
+
6
+ def is_valid_project_name(name: str) -> bool:
7
+ if not name or not name[0].isalpha():
8
+ return False
9
+ if not re.fullmatch(r"[A-Za-z0-9_-]+", name):
10
+ return False
11
+ if name.startswith(("-", "_")) or name.endswith(("-", "_")):
12
+ return False
13
+ if "__" in name or "--" in name:
14
+ return False
15
+ return True
16
+
17
+
18
+ def _title_part(part: str) -> str:
19
+ if not part:
20
+ return ""
21
+ if part.isdigit():
22
+ return part
23
+ return part[0].upper() + part[1:]
24
+
25
+
26
+ def to_pascal_case(name: str) -> str:
27
+ if "_" in name:
28
+ parts = name.split("_")
29
+ elif "-" in name:
30
+ parts = name.split("-")
31
+ else:
32
+ parts = _CAMEL_PARTS.findall(name) or [name]
33
+
34
+ return "".join(_title_part(part) for part in parts if part)
stackforge/scaffold.py CHANGED
@@ -1,83 +1,80 @@
1
1
  from pathlib import Path
2
2
  from stackforge.engines.dotnet.scaffolder import scaffold_folders
3
- from colorama import init, Fore, Style
4
- import re
5
-
6
- init(autoreset=True)
7
-
8
- def is_valid_project_name(name: str) -> bool:
9
- return bool(re.match(r'^[A-Za-z][A-Za-z0-9]*$', name))
3
+ from stackforge.version import get_installed_version, notify_if_update_available
4
+ from stackforge.project_name import is_valid_project_name, to_pascal_case
5
+ from stackforge import ui
6
+ import sys
10
7
 
11
8
 
12
9
  def select_framework() -> str:
13
- print(f" {Fore.CYAN}Select a framework:{Style.RESET_ALL}\n")
14
- print(f" {Fore.GREEN}1.{Style.RESET_ALL} .NET Clean Architecture (CQRS)")
15
- print(f" {Fore.YELLOW}2.{Style.RESET_ALL} Django [coming soon]")
16
- print(f" {Fore.YELLOW}3.{Style.RESET_ALL} FastAPI [coming soon]")
17
- print(f" {Fore.YELLOW}4.{Style.RESET_ALL} Flask [coming soon]")
18
- print(f" {Fore.RED}5.{Style.RESET_ALL} exit")
19
-
20
- choice = input(f"\n {Fore.CYAN}Choice [n]:{Style.RESET_ALL} ").strip() or "1"
10
+ ui.info("\n Select a framework:\n")
11
+ ui.menu_option("1", ".NET Clean Architecture (CQRS)")
12
+ ui.menu_option("2", "Django [coming soon]", style=ui.Fore.YELLOW)
13
+ ui.menu_option("3", "FastAPI [coming soon]", style=ui.Fore.YELLOW)
14
+ ui.menu_option("4", "Flask [coming soon]", style=ui.Fore.YELLOW)
15
+ ui.menu_option("5", "exit", style=ui.Fore.RED)
16
+
17
+ choice = ui.prompt("\n Choice [1]:") or "1"
21
18
  return choice
22
19
 
23
20
 
24
21
  def main():
25
- print(Fore.CYAN + r"""
26
- _____ _ _ ______
27
- / ____| | | | | ____|
28
- | (___ | |_ __ _ ___| | _| |__ ___ _ __ __ _ ___
29
- \___ \| __/ _` |/ __| |/ / __/ _ \| '__/ _` |/ _ \
30
- ____) | || (_| | (__| <| | | (_) | | | (_| | __/
31
- |_____/ \__\__,_|\___|_|\_\_| \___/|_| \__, |\___|
32
- __/ |
33
- |___/
34
- """ + Style.RESET_ALL + f" {Fore.WHITE}.NET Clean Architecture Scaffolder{Style.RESET_ALL}\n")
22
+ if "--version" in sys.argv or "-V" in sys.argv:
23
+ print(get_installed_version())
24
+ return
25
+
26
+ notify_if_update_available()
27
+ ui.banner(".NET Clean Architecture Scaffolder", get_installed_version())
28
+ print()
35
29
 
36
30
  while True:
37
31
  framework = select_framework()
38
32
 
39
33
  if framework == "5":
40
- print(f"\n {Fore.YELLOW}Exiting...{Style.RESET_ALL}")
34
+ ui.warn("\n Exiting...")
41
35
  break
42
36
 
43
37
  if framework != "1":
44
- print(f"\n {Fore.YELLOW}[!] This framework is under development. Stay tuned!{Style.RESET_ALL}\n")
38
+ ui.warn("\n This framework is under development. Stay tuned!\n")
45
39
  continue
46
40
 
47
- project_name = input(f"\n {Fore.CYAN}Enter project name (PascalCase, no spaces):{Style.RESET_ALL} ").strip()
41
+ raw_name = ui.prompt(
42
+ "\n Enter project name (PascalCase, camelCase, snake_case, or kebab-case):"
43
+ )
48
44
 
49
- if not project_name:
50
- print(f" {Fore.RED}[!] Project name cannot be empty.{Style.RESET_ALL}\n")
45
+ if not raw_name:
46
+ ui.error("Project name cannot be empty.\n")
51
47
  continue
52
48
 
53
- if not is_valid_project_name(project_name):
54
- print(f" {Fore.RED}[!] Project name must start with a letter and contain only letters and numbers.")
55
- print(f" Example: RaiderXpress, MyApi, StackForge{Style.RESET_ALL}\n")
49
+ if not is_valid_project_name(raw_name):
50
+ ui.error("Invalid project name. Use letters, numbers, hyphens, or underscores.")
51
+ ui.step("Examples: MyApi, myApi, my_api, my-api\n")
56
52
  continue
57
53
 
54
+ project_name = to_pascal_case(raw_name)
55
+ if project_name != raw_name:
56
+ ui.info(f" Normalized to: {project_name}")
57
+
58
58
  base_path = Path.home() / "stackforge" / project_name
59
59
 
60
60
  if base_path.exists():
61
- print(f"\n {Fore.RED}[!] Project '{project_name}' already exists in the stackforge workspace.")
62
- print(f" Path: {base_path}{Style.RESET_ALL}")
63
- print(" Choose a different project name or delete the existing one.\n")
61
+ ui.error(f"\n Project '{project_name}' already exists in the stackforge workspace.")
62
+ ui.step(f"Path: {base_path}")
63
+ ui.step("Choose a different project name or delete the existing one.\n")
64
64
  continue
65
65
 
66
66
  base_path.mkdir(parents=True, exist_ok=True)
67
67
  scaffold_folders(base_path, project_name)
68
68
 
69
- print(f"""
70
- {Fore.GREEN}✔ Project '{project_name}' created successfully!
71
- ✔ Location: {base_path}{Style.RESET_ALL}
72
-
73
- {Fore.CYAN}Next steps:{Style.RESET_ALL}
74
- 1. Open the project in Visual Studio or VS Code
75
- 2. Run: docker-compose up --build
76
- 3. Visit: http://localhost:5000/swagger
77
-
78
- Press Ctrl+C to exit or continue to scaffold another project.
79
- """)
69
+ ui.section("Project ready")
70
+ ui.success(f"Created '{project_name}'")
71
+ ui.success(f"Location: {base_path}")
72
+ ui.info("\n Next steps:")
73
+ ui.step("Open the project in Visual Studio or VS Code")
74
+ ui.step("Run: docker-compose up --build")
75
+ ui.step("Visit: http://localhost:5000/swagger")
76
+ ui.muted("\n Press Ctrl+C to exit or continue to scaffold another project.\n")
80
77
 
81
78
 
82
79
  if __name__ == "__main__":
83
- main()
80
+ main()
stackforge/ui.py ADDED
@@ -0,0 +1,72 @@
1
+ from colorama import Fore, Style, init
2
+
3
+ init(autoreset=True)
4
+
5
+ __all__ = [
6
+ "BANNER", "banner", "section", "step", "file_created", "success",
7
+ "warn", "error", "info", "prompt", "menu_option", "done", "muted",
8
+ "Fore", "Style",
9
+ ]
10
+
11
+ BANNER = r"""
12
+ _____ _ _ ______
13
+ / ____| | | | | ____|
14
+ | (___ | |_ __ _ ___| | _| |__ ___ _ __ __ _ ___
15
+ \___ \| __/ _` |/ __| |/ / __/ _ \| '__/ _` |/ _ \
16
+ ____) | || (_| | (__| <| | | (_) | | | (_| | __/
17
+ |_____/ \__\__,_|\___|_|\_\_| \___/|_| \__, |\___|
18
+ __/ |
19
+ |___/"""
20
+
21
+
22
+ def banner(subtitle: str, version: str = "") -> None:
23
+ print(f"{Style.BRIGHT}{Fore.CYAN}{BANNER}{Style.RESET_ALL}")
24
+ print(f" {Style.BRIGHT}{Fore.WHITE}{subtitle}{Style.RESET_ALL}", end="")
25
+ if version:
26
+ print(f" {Fore.LIGHTBLACK_EX}v{version}{Style.RESET_ALL}")
27
+ else:
28
+ print()
29
+
30
+
31
+ def section(title: str) -> None:
32
+ print(f"\n {Style.BRIGHT}{Fore.CYAN}> {title}{Style.RESET_ALL}")
33
+
34
+
35
+ def step(label: str) -> None:
36
+ print(f" {Fore.BLUE}|{Style.RESET_ALL} {label}")
37
+
38
+
39
+ def file_created(path: str) -> None:
40
+ print(f" {Fore.GREEN}+{Style.RESET_ALL} {Fore.LIGHTWHITE_EX}{path}{Style.RESET_ALL}")
41
+
42
+
43
+ def success(message: str) -> None:
44
+ print(f" {Fore.GREEN}+{Style.RESET_ALL} {message}")
45
+
46
+
47
+ def warn(message: str) -> None:
48
+ print(f" {Fore.YELLOW}!{Style.RESET_ALL} {message}")
49
+
50
+
51
+ def error(message: str) -> None:
52
+ print(f" {Fore.RED}x{Style.RESET_ALL} {message}")
53
+
54
+
55
+ def info(message: str) -> None:
56
+ print(f" {Fore.CYAN}{message}{Style.RESET_ALL}")
57
+
58
+
59
+ def prompt(label: str) -> str:
60
+ return input(f" {Style.BRIGHT}{Fore.CYAN}{label}{Style.RESET_ALL} ").strip()
61
+
62
+
63
+ def menu_option(number: str, label: str, *, style: str = Fore.GREEN) -> None:
64
+ print(f" {style}{number}.{Style.RESET_ALL} {label}")
65
+
66
+
67
+ def done() -> None:
68
+ print(f"\n {Style.BRIGHT}{Fore.GREEN}+ Scaffold complete.{Style.RESET_ALL}")
69
+
70
+
71
+ def muted(message: str) -> None:
72
+ print(f" {Fore.LIGHTBLACK_EX}{message}{Style.RESET_ALL}")
stackforge/version.py ADDED
@@ -0,0 +1,48 @@
1
+ import json
2
+ import urllib.error
3
+ import urllib.request
4
+ from importlib.metadata import PackageNotFoundError, version
5
+
6
+ PACKAGE_NAME = "stackforge-cli"
7
+ PYPI_JSON_URL = f"https://pypi.org/pypi/{PACKAGE_NAME}/json"
8
+
9
+
10
+ def get_installed_version() -> str:
11
+ try:
12
+ return version(PACKAGE_NAME)
13
+ except PackageNotFoundError:
14
+ return "0.0.0-dev"
15
+
16
+
17
+ def _version_tuple(value: str) -> tuple[int, ...]:
18
+ parts: list[int] = []
19
+ for segment in value.split("."):
20
+ digits = "".join(c for c in segment if c.isdigit())
21
+ if digits:
22
+ parts.append(int(digits))
23
+ return tuple(parts)
24
+
25
+
26
+ def fetch_latest_version(timeout: float = 2.0) -> str | None:
27
+ request = urllib.request.Request(
28
+ PYPI_JSON_URL,
29
+ headers={"Accept": "application/json"},
30
+ )
31
+ try:
32
+ with urllib.request.urlopen(request, timeout=timeout) as response:
33
+ payload = json.load(response)
34
+ return payload["info"]["version"]
35
+ except (urllib.error.URLError, TimeoutError, KeyError, json.JSONDecodeError):
36
+ return None
37
+
38
+
39
+ def notify_if_update_available() -> None:
40
+ from stackforge import ui
41
+
42
+ installed = get_installed_version()
43
+ latest = fetch_latest_version()
44
+ if not latest or _version_tuple(latest) <= _version_tuple(installed):
45
+ return
46
+
47
+ ui.warn(f"StackForge {latest} is available (you have {installed}).")
48
+ ui.step(f"Update: pip install --upgrade {PACKAGE_NAME}\n")
@@ -0,0 +1,107 @@
1
+ Metadata-Version: 2.4
2
+ Name: stackforge-cli
3
+ Version: 0.1.2
4
+ Summary: A CLI scaffolder for .NET Clean Architecture projects
5
+ License: MIT
6
+ Keywords: scaffolder,dotnet,clean-architecture,cli
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Environment :: Console
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: colorama>=0.4.6
14
+
15
+ # StackForge
16
+
17
+ A CLI scaffolder for .NET Clean Architecture (CQRS) projects.
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install stackforge-cli
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ```bash
28
+ stackforge
29
+ ```
30
+
31
+ Then follow the prompts to scaffold a new project.
32
+
33
+ ## Version and updates
34
+
35
+ Check the version you have installed:
36
+
37
+ ```bash
38
+ stackforge --version
39
+ ```
40
+
41
+ Update to the latest release:
42
+
43
+ ```bash
44
+ pip install --upgrade stackforge-cli
45
+ ```
46
+
47
+ When you run `stackforge`, it checks PyPI for a newer version and prints an upgrade notice if one is available (network required; fails silently if offline).
48
+
49
+ ## What it generates
50
+
51
+ - .NET 10 Clean Architecture structure (API, Application, Domain, Infrastructure, Persistence)
52
+ - JWT authentication with ASP.NET Identity
53
+ - Swagger UI with Bearer token support
54
+ - PostgreSQL with EF Core
55
+ - Docker + docker-compose with healthchecks
56
+ - Role and user seeders (SuperAdmin out of the box)
57
+ - Git initialization on `main` with `staging` and `development` branches
58
+ - GitHub Actions workflow to create `staging` and `development` on first push to `main`
59
+
60
+ ## Quickstart after scaffolding
61
+
62
+ 1. Open the project in VS Code or Visual Studio
63
+ 2. Run: `docker-compose up --build`
64
+ 3. Visit: `http://localhost:5000/swagger`
65
+
66
+ ## Git workflow
67
+
68
+ Each scaffolded project is initialized with three local branches:
69
+
70
+ | Branch | Purpose |
71
+ |---------------|----------------------------------|
72
+ | `main` | Production / default branch |
73
+ | `staging` | Pre-production environment |
74
+ | `development` | Active development environment |
75
+
76
+ A GitHub Actions workflow (`.github/workflows/sync-branches.yml`) is also included as a fallback: if you only push `main` first, it creates remote `staging` and `development` on GitHub automatically.
77
+
78
+ ### Example: push to GitHub
79
+
80
+ From your scaffolded project directory (e.g. `~/stackforge/MyApi`):
81
+
82
+ ```bash
83
+ # 1. Create a new repo on GitHub (empty, no README), then add the remote
84
+ git remote add origin https://github.com/<your-user>/MyApi.git
85
+
86
+ # 2. Push all branches in one go
87
+ git push -u origin --all
88
+ ```
89
+
90
+ That publishes `main`, `staging`, and `development` in a single command and sets upstream tracking for each.
91
+
92
+ ### Day-to-day branching
93
+
94
+ ```bash
95
+ # Work on a feature
96
+ git checkout development
97
+ git checkout -b feature/my-feature
98
+ # ... commit changes ...
99
+ git push -u origin feature/my-feature
100
+
101
+ # Merge into development when ready (via PR or locally)
102
+ git checkout development
103
+ git merge feature/my-feature
104
+ git push origin development
105
+ ```
106
+
107
+ Promote changes up the chain (`development` → `staging` → `main`) using pull requests or merges as your team prefers.
@@ -0,0 +1,19 @@
1
+ stackforge/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ stackforge/project_name.py,sha256=opPJncCuWnysCpS9wLSk_uzC4BJ6ow2eG4sTr0AIdlc,885
3
+ stackforge/scaffold.py,sha256=nKLkYUvSVY_W9w2VjJG3SWaFZFlEYUpUs4geQwi61Q4,2923
4
+ stackforge/ui.py,sha256=K-47CSFIjYdT2oyjWWHdSc69SgfFGy0q69ksG6UVuRc,2160
5
+ stackforge/version.py,sha256=bz93n0b69WPdYgJW5tCvL3fLU2E9RStCkJtgue7_7S0,1484
6
+ stackforge/engines/dotnet/__init__.py,sha256=I6S1SzyFstXO182w9qnKzlGQF0ffOfrg5Tkt9QAHRLw,618
7
+ stackforge/engines/dotnet/api_generator.py,sha256=gTXDiSNbeIL07KQahQ5BxrrqZhqqaSjGVffn0SISWa8,9814
8
+ stackforge/engines/dotnet/config_generator.py,sha256=Pn9VcS18rgpuPWnCh4Lhi2X1rr3wmvlQhc892DmNQ-0,2069
9
+ stackforge/engines/dotnet/csproj_generator.py,sha256=gVnWzduCPk5OOnTWz_5TvrOGhq4ms4PLL1lLGY-1_TI,2514
10
+ stackforge/engines/dotnet/docker_generator.py,sha256=NBhx0aT0_0Zk3F5FOTrq4flKGFkUBVQF0tml1hVGIrQ,1659
11
+ stackforge/engines/dotnet/git_generator.py,sha256=c7Q8y8PvZHR33_veAklv200tHw46Z3nIBjDAsYAyEgQ,3058
12
+ stackforge/engines/dotnet/layers_generator.py,sha256=HoXztxUR4StmMktKzCmbJjj5MjuUvw3NNSQOjA3LulQ,18175
13
+ stackforge/engines/dotnet/program_generator.py,sha256=kvKkaQTLtSu_SGV4lfkdo-mX3z-fLKwRWG8ZvhZ053Q,6072
14
+ stackforge/engines/dotnet/scaffolder.py,sha256=eU02zDIQ5TSZaosQo15cIYmRMn2knzzNLRH5iG8OYRI,2387
15
+ stackforge_cli-0.1.2.dist-info/METADATA,sha256=sYTVyqdndDXLCg98gKqaPfLagsH7rc3gStk4RMTWdns,3179
16
+ stackforge_cli-0.1.2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
17
+ stackforge_cli-0.1.2.dist-info/entry_points.txt,sha256=r6YqYMrqMdXBiKTqSNdbEjwuzhCSksAlAmdhnqIOvJE,56
18
+ stackforge_cli-0.1.2.dist-info/top_level.txt,sha256=rLeEUKSWLyFKeW9uVuvTDIxq05hOic0cG7Xy3XlSYI8,11
19
+ stackforge_cli-0.1.2.dist-info/RECORD,,
@@ -1,47 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: stackforge-cli
3
- Version: 0.1.1
4
- Summary: A CLI scaffolder for .NET Clean Architecture projects
5
- License: MIT
6
- Keywords: scaffolder,dotnet,clean-architecture,cli
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Operating System :: OS Independent
10
- Classifier: Environment :: Console
11
- Requires-Python: >=3.10
12
- Description-Content-Type: text/markdown
13
- Requires-Dist: colorama>=0.4.6
14
-
15
- # StackForge
16
-
17
- A CLI scaffolder for .NET Clean Architecture (CQRS) projects.
18
-
19
- ## Installation
20
-
21
- ```bash
22
- pip install stackforge
23
- ```
24
-
25
- ## Usage
26
-
27
- ```bash
28
- stackforge
29
- ```
30
-
31
- Then follow the prompts to scaffold a new project.
32
-
33
- ## What it generates
34
-
35
- - .NET 10 Clean Architecture structure (API, Application, Domain, Infrastructure, Persistence)
36
- - JWT authentication with ASP.NET Identity
37
- - Swagger UI with Bearer token support
38
- - PostgreSQL with EF Core
39
- - Docker + docker-compose with healthchecks
40
- - Role and user seeders (SuperAdmin out of the box)
41
- - Git initialization with initial commit
42
-
43
- ## Quickstart after scaffolding
44
-
45
- 1. Open the project in VS Code or Visual Studio
46
- 2. Run: `docker-compose up --build`
47
- 3. Visit: `http://localhost:5000/swagger`
@@ -1,16 +0,0 @@
1
- stackforge/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- stackforge/scaffold.py,sha256=M4NR0_-kN09AfAtiXiqnNCxFYfrpVeYGx7UzjAdce-g,3261
3
- stackforge/engines/dotnet/__init__.py,sha256=bxCYj7mEmcLZZ06vgUPe8l9_PAp_dTDYLbaVK7sotQM,592
4
- stackforge/engines/dotnet/api_generator.py,sha256=06dPkqhqadIV2xNrlrMzNNvf9n2iG2zro8lzZ6jk-uw,9783
5
- stackforge/engines/dotnet/config_generator.py,sha256=cEKpUJ9t6gRNk9TnWQ1LXrxUk1WYLxDw_DH8T-X7gvA,2030
6
- stackforge/engines/dotnet/csproj_generator.py,sha256=aGoqkJLIVggTxM_tlyMH_RESI4Qy0BY6Pdo3OJLF7ao,2483
7
- stackforge/engines/dotnet/docker_generator.py,sha256=V4r2UKcMAR92-3yJBXjVfo1u-_HOtw9Zf2mrAp7bjDM,1624
8
- stackforge/engines/dotnet/git_generator.py,sha256=_fRnGnMLitw5GPxt1yKVCwCDequpMF-XZe-qYzSn6Gs,1718
9
- stackforge/engines/dotnet/layers_generator.py,sha256=EM5agcRcZAL_9s980sEP1iECuE518O-L6NndFtH3U2o,18132
10
- stackforge/engines/dotnet/program_generator.py,sha256=bCjTI8-aY9kLOOVZASF9U8HIEkVgOhtAndkV0Sq8V10,6037
11
- stackforge/engines/dotnet/scaffolder.py,sha256=Tco9MnM-qEBkTps472inZ62rTAcnecwpUBvAofE56gY,2289
12
- stackforge_cli-0.1.1.dist-info/METADATA,sha256=epE-WLMVrdm6pe6wfW6DvjSYFLSQYYGbNEGv3P_sa6s,1247
13
- stackforge_cli-0.1.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
14
- stackforge_cli-0.1.1.dist-info/entry_points.txt,sha256=r6YqYMrqMdXBiKTqSNdbEjwuzhCSksAlAmdhnqIOvJE,56
15
- stackforge_cli-0.1.1.dist-info/top_level.txt,sha256=rLeEUKSWLyFKeW9uVuvTDIxq05hOic0cG7Xy3XlSYI8,11
16
- stackforge_cli-0.1.1.dist-info/RECORD,,