Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# Environnements virtuels Python
venv/
env/
.env

# Cache et fichiers compilés Python
__pycache__/
*.py[cod]
*$py.class

# Fichiers de build Typer / Setuptools
build/
# Cache et fichiers compilés Python
devctl.egg-info/
dist/
*.egg-info/

# Dossier pycharm
.idea/
*.egg-info/
.env
env/
# Environnements virtuels Python
# Fichiers de build Typer / Setuptools
.idea/devctl.egg-info/
__pycache__/
*.py[cod]
venv/
6 changes: 3 additions & 3 deletions devctl/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import typer

# Angular generator
# Angular Generator
from devctl.generators.angular import generate_angular_boilerplate
from devctl.generators.django import generate_django_boilerplate
from devctl.generators.fastapi import generate_fastapi_boilerplate
Expand All @@ -16,14 +16,14 @@
from devctl.generators.nodejs import generate_nodejs_boilerplate
from devctl.generators.react import generate_react_boilerplate

# Spring generator
# Spring Generator
from devctl.generators.spring import download_spring_boilerplate
from devctl.generators.svelte import generate_svelte_boilerplate
from devctl.generators.vue import generate_vue_boilerplate
from devctl.orchestrator.config_builder import generate_config
from devctl.utils.dependencies import check_tool

# Local Typer application for "init" command group
# Local Typer app for the "init" command group
app = typer.Typer(help="Initializes a new project based on the chosen framework.")


Expand Down
4 changes: 2 additions & 2 deletions devctl/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ def get_status(condition: bool):
typer.secho("\nError: No valid development environment detected here.", fg=typer.colors.RED)
raise typer.Exit(code=1)

# Transfer control to the system orchestration layer
launch_dev_environment(projects, docker_composes)
# Hand off to the system orchestration layer
launch_dev_environment(env_state)
8 changes: 4 additions & 4 deletions devctl/generators/angular.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def setup_angular_environments(project_path: str):
with open(target_path, "w", encoding="utf-8") as f:
f.write(content)
except Exception as e:
typer.secho(f"Warning: Failed to generate {tpl_name}: {e}", fg=typer.colors.YELLOW)
typer.secho(f"⚠️ Error while generating {tpl_name}: {e}", fg=typer.colors.YELLOW)

# 3. Modify angular.json to enable the proxy
angular_json_path = os.path.join(project_path, "angular.json")
Expand All @@ -48,10 +48,10 @@ def setup_angular_environments(project_path: str):
angular_config = json.load(f)

try:
# Find the default project name (usually the same name as the folder)
# Find the default project name (usually the same as the folder name)
project_name = list(angular_config["projects"].keys())[0]

# Injection of proxyConfig into the "serve" architect
# Inject proxyConfig into the "serve" architect
serve_target = angular_config["projects"][project_name]["architect"]["serve"]

# Ensure "options" exists
Expand All @@ -66,7 +66,7 @@ def setup_angular_environments(project_path: str):
typer.echo(" - angular.json updated with proxyConfig.")
except Exception as e:
typer.secho(
f"Warning: Unable to modify angular.json automatically: {e}",
f"⚠️ Could not automatically modify angular.json: {e}",
fg=typer.colors.YELLOW,
)

Expand Down
6 changes: 3 additions & 3 deletions devctl/generators/scaffold_angular.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def parse_ts_fields(fields_str: str):

def generate_angular_resource(resource_name: str, fields_str: str, root_path: str = "."):
"""
Orchestrates the creation of a complete Angular feature.
Orchestrates the creation of the complete Angular feature.
"""
env_state = detect_environment(root_path)

Expand All @@ -50,10 +50,10 @@ def generate_angular_resource(resource_name: str, fields_str: str, root_path: st
resource_lower = resource_name.lower()
entity_name = resource_name.capitalize()

# Feature target directory: src/app/features/resource_name
# The target feature directory: src/app/features/produit
feature_dir = os.path.join(angular_root, "src", "app", "features", resource_lower)

# Components to generate
# Component configuration to generate
components = [
# Models
{
Expand Down
14 changes: 7 additions & 7 deletions devctl/generators/scaffold_spring.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

def parse_fields(fields_str: str):
"""
Transforms terminal field strings into injectable data.
Transforms terminal string into injectable data.
Example: "name:string, age:int" -> [{"name": "name", "java_type": "String"}, ...]
"""
if not fields_str:
Expand All @@ -42,8 +42,8 @@ def parse_fields(fields_str: str):

def find_spring_base_package_and_path():
"""
Searches for the directory containing the @SpringBootApplication class.
This is the most reliable way to find the base package without parsing pom.xml.
Searches for the folder containing the @SpringBootApplication class.
This is the most reliable method to find the base package without parsing pom.xml.
"""
java_src_dir = os.path.join(os.getcwd(), "src", "main", "java")

Expand All @@ -62,7 +62,7 @@ def find_spring_base_package_and_path():

def generate_spring_resource(resource_name: str, fields_str: str):
"""
Orchestrates the creation of MVC + DTOs + Mapper architecture.
Orchestrates the creation of the MVC + DTOs + Mapper architecture.
"""
base_package, base_path = find_spring_base_package_and_path()

Expand All @@ -75,7 +75,7 @@ def generate_spring_resource(resource_name: str, fields_str: str):

entity_name = resource_name.capitalize()

# Detailed configuration for sub-folders (DTOs, Mappers)
# New detailed configuration to handle sub-folders (DTOs, Mapper)
components = [
{"dir": "entity", "suffix": "Entity", "template": "Entity.java.j2"},
{"dir": "repository", "suffix": "Repository", "template": "Repository.java.j2"},
Expand All @@ -100,11 +100,11 @@ def generate_spring_resource(resource_name: str, fields_str: str):
target_file_name = f"{class_name}.java"

# Create sub-folder if it doesn't exist (e.g., src/.../dto/request)
# os.path.normpath handles OS-specific slashes
# os.path.normpath handles slashes depending on the OS (Linux/Windows)
target_dir = os.path.join(base_path, os.path.normpath(comp["dir"]))
os.makedirs(target_dir, exist_ok=True)

# Data passed to the Jinja2 template
# Template data for Jinja2
context = {
"base_package": base_package,
"class_name": class_name,
Expand Down
2 changes: 1 addition & 1 deletion devctl/generators/spring.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def download_spring_boilerplate(project_name: str, db_type: str = "postgres"):
fg=typer.colors.CYAN,
)

# Java rule: a package name cannot contain hyphens
# Java rule: a package name cannot contain dashes
safe_package_name = project_name.replace("-", "").replace("_", "").lower()

# Dynamic mapping for the Spring API
Expand Down
6 changes: 3 additions & 3 deletions devctl/generators/vue.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ def setup_vue_router(project_path: str):
typer.secho("Installing and configuring vue-router...", fg=typer.colors.CYAN)

try:
# 1. NPM package installation
# 1. Install npm package
subprocess.run(
["npm", "install", "vue-router@4"],
cwd=project_path,
check=True,
stdout=subprocess.DEVNULL,
)

# 2. Router directory creation
# 2. Create router directory
src_dir = os.path.join(project_path, "src")
router_dir = os.path.join(src_dir, "router")
os.makedirs(router_dir, exist_ok=True)

# 3. Jinja2 template rendering
# 3. Render Jinja2 templates
templates_dir = os.path.join(os.path.dirname(__file__), "..", "templates", "vue", "config")
env = Environment(loader=FileSystemLoader(templates_dir))

Expand Down
8 changes: 4 additions & 4 deletions devctl/main.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import typer

# Import command modules
from devctl.commands import add, deploy, docker, init, run
from devctl.commands import add, docker, init, run

# Create the main Typer application
app = typer.Typer(help="devctl: Local orchestrator for your Spring/Angular projects")

# Register sub-commands
# Register sub-menus
app.add_typer(init.app, name="init", help="Initialize a new project with its codebase.")
app.add_typer(run.app, name="run", help="Launch the local development environment in parallel.")
app.add_typer(add.app, name="add", help="Generate code and business resources.")
Expand All @@ -22,7 +22,7 @@ def callback():
"""
devctl: Local orchestrator for your projects
"""
# This empty callback allows Typer to understand it handles a multi-command menu
# This empty callback allows Typer to understand it's managing a multi-command menu
pass


Expand All @@ -36,7 +36,7 @@ def ping():

def main():
"""
Entry point called by the operating system (via pyproject.toml)
Application entry point called by the OS (via pyproject.toml)
"""
app()

Expand Down
Loading
Loading