Compare commits
6 Commits
2025.10.19
...
2025.10.19
| Author | SHA1 | Date | |
|---|---|---|---|
| e3b19c9984 | |||
| 91269f351b | |||
| 5d07973940 | |||
| 0a9b7b81be | |||
| 21c88bc442 | |||
| 04e0884e1c |
22
README.md
22
README.md
@@ -0,0 +1,22 @@
|
||||
## Prepare for development
|
||||
|
||||
After cloning the repository, run the following commands to set up your development environment:
|
||||
|
||||
```bash
|
||||
python -m venv .venv
|
||||
source .venv/bin/activate
|
||||
# On Windows use `.venv\Scripts\activate`
|
||||
# On Windows with git bash use `source .venv/Scripts/activate`
|
||||
bash install.sh
|
||||
```
|
||||
|
||||
Install cpl-cli as a development package:
|
||||
|
||||
```bash
|
||||
pip install -e src/core
|
||||
pip install -e src/cli
|
||||
# test with:
|
||||
cpl v
|
||||
```
|
||||
|
||||
When using Pycharm, mark all directories under `src/` as "Sources Root" and `exa` to ensure proper module resolution.
|
||||
@@ -1,15 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Find and combine requirements from src/cpl-*/requirements.txt,
|
||||
# Find and combine requirements from src/*/requirements.txt,
|
||||
# filtering out lines whose *package name* starts with "cpl-".
|
||||
# Works with pinned versions, extras, markers, editable installs, and VCS refs.
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
req_files=(src/cpl-*/requirements.txt)
|
||||
req_files=(src/*/requirements.txt)
|
||||
if ((${#req_files[@]} == 0)); then
|
||||
echo "No requirements files found at src/cpl-*/requirements.txt" >&2
|
||||
echo "No requirements files found at src/*/requirements.txt" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ from cpl.core.console import Console
|
||||
@click.command("init")
|
||||
@click.argument("target", required=False)
|
||||
@click.argument("name", required=False)
|
||||
def init(target: str, name: str):
|
||||
@click.option("--verbose", "-v", is_flag=True, help="Enable verbose output")
|
||||
def init(target: str, name: str, verbose: bool = False):
|
||||
workspace = None
|
||||
project = None
|
||||
|
||||
@@ -30,9 +31,9 @@ def init(target: str, name: str):
|
||||
if target in ["workspace", "ws"]:
|
||||
workspace = Structure.init_workspace("./", name or click.prompt("Workspace name", default="my-workspace"))
|
||||
elif target in PROJECT_TYPES:
|
||||
workspace = Structure.find_workspace_in_path(Path(name).parent)
|
||||
workspace = Structure.find_workspace_in_path(Path(name or "./").parent, with_parents=True)
|
||||
project = Structure.init_project(
|
||||
"./", name or click.prompt("Project name", default=f"my-{target}"), target, workspace
|
||||
"./", name or click.prompt("Project name", default=f"my-{target}"), target, workspace, verbose=verbose
|
||||
)
|
||||
else:
|
||||
Console.error(f"Unknown target '{target}'")
|
||||
|
||||
@@ -84,7 +84,7 @@ class Structure:
|
||||
|
||||
return Project.from_file(path)
|
||||
|
||||
workspace = Structure.find_workspace_in_path(path.parent)
|
||||
workspace = Structure.find_workspace_in_path(path.parent, with_parents=True)
|
||||
if workspace is None:
|
||||
raise RuntimeError("No workspace found. Please run 'cpl init workspace' first.")
|
||||
|
||||
@@ -138,6 +138,16 @@ class Structure:
|
||||
)
|
||||
|
||||
project.save()
|
||||
Console.write_line(f"Created {project_type} project '{name}'")
|
||||
|
||||
if workspace is not None:
|
||||
rel_path = str(path.resolve().absolute().relative_to(Path(workspace.path).parent)).replace("\\", "/")
|
||||
if rel_path not in workspace.projects:
|
||||
workspace.projects.append(rel_path)
|
||||
workspace.save()
|
||||
|
||||
if verbose:
|
||||
Console.write_line(f"Registered '{name}' in workspace.json")
|
||||
|
||||
from cpl.cli.command.package.install import install
|
||||
|
||||
@@ -149,17 +159,6 @@ class Structure:
|
||||
install.callback(package, project.name, dev=False, verbose=verbose)
|
||||
|
||||
os.chdir(old_cwd)
|
||||
|
||||
if workspace is not None:
|
||||
rel_path = str(path.resolve().absolute().relative_to(Path(workspace.path).parent))
|
||||
if rel_path not in workspace.projects:
|
||||
workspace.projects.append(rel_path)
|
||||
workspace.save()
|
||||
|
||||
if verbose:
|
||||
Console.write_line(f"Registered '{name}' in workspace.json")
|
||||
|
||||
Console.write_line(f"Created {project_type} project '{name}'")
|
||||
return project
|
||||
|
||||
@staticmethod
|
||||
@@ -199,4 +198,4 @@ class Structure:
|
||||
shutil.copy(src_file, tgt_file)
|
||||
|
||||
Console.write_line()
|
||||
Structure.init_project(str(path), name, project_type, workspace)
|
||||
Structure.init_project(str(path), name, project_type, workspace, verbose=verbose)
|
||||
|
||||
Reference in New Issue
Block a user