Compare commits
2 Commits
2025.10.19
...
2025.10.19
| Author | SHA1 | Date | |
|---|---|---|---|
| e3b19c9984 | |||
| 91269f351b |
@@ -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.")
|
||||
|
||||
@@ -116,7 +116,7 @@ class Structure:
|
||||
return workspace
|
||||
|
||||
@staticmethod
|
||||
def init_project(rel_path: str, name: str, project_type: str, workspace: Workspace | None, install_deps=False, verbose=False):
|
||||
def init_project(rel_path: str, name: str, project_type: str, workspace: Workspace | None, verbose=False):
|
||||
if not Path(rel_path).exists():
|
||||
rel_path = click.prompt("Project directory", type=click.Path(exists=True, file_okay=False), default="src")
|
||||
|
||||
@@ -138,21 +138,10 @@ class Structure:
|
||||
)
|
||||
|
||||
project.save()
|
||||
|
||||
if install_deps:
|
||||
from cpl.cli.command.package.install import install
|
||||
|
||||
old_cwd = os.getcwd()
|
||||
os.chdir(Path(workspace.path).parent)
|
||||
install.callback(f"cpl-cli>={cli.__version__}", project.name, dev=True, verbose=verbose)
|
||||
if project_type in Structure._dependency_map:
|
||||
for package in Structure._dependency_map[project_type]:
|
||||
install.callback(package, project.name, dev=False, verbose=verbose)
|
||||
|
||||
os.chdir(old_cwd)
|
||||
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))
|
||||
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()
|
||||
@@ -160,7 +149,16 @@ class Structure:
|
||||
if verbose:
|
||||
Console.write_line(f"Registered '{name}' in workspace.json")
|
||||
|
||||
Console.write_line(f"Created {project_type} project '{name}'")
|
||||
from cpl.cli.command.package.install import install
|
||||
|
||||
old_cwd = os.getcwd()
|
||||
os.chdir(Path(workspace.path).parent)
|
||||
install.callback(f"cpl-cli>={cli.__version__}", project.name, dev=True, verbose=verbose)
|
||||
if project_type in Structure._dependency_map:
|
||||
for package in Structure._dependency_map[project_type]:
|
||||
install.callback(package, project.name, dev=False, verbose=verbose)
|
||||
|
||||
os.chdir(old_cwd)
|
||||
return project
|
||||
|
||||
@staticmethod
|
||||
@@ -200,4 +198,4 @@ class Structure:
|
||||
shutil.copy(src_file, tgt_file)
|
||||
|
||||
Console.write_line()
|
||||
Structure.init_project(str(path), name, project_type, workspace, install_deps=True, verbose=verbose)
|
||||
Structure.init_project(str(path), name, project_type, workspace, verbose=verbose)
|
||||
|
||||
Reference in New Issue
Block a user