Fixed init command regarding package handling
Some checks failed
Test before pr merge / test-lint (pull_request) Failing after 7s
Build on push / prepare (push) Successful in 11s
Build on push / core (push) Successful in 19s
Build on push / query (push) Successful in 20s
Build on push / cli (push) Successful in 19s
Build on push / dependency (push) Successful in 22s
Build on push / database (push) Successful in 16s
Build on push / translation (push) Successful in 16s
Build on push / mail (push) Successful in 17s
Build on push / application (push) Successful in 17s
Build on push / auth (push) Successful in 18s
Build on push / api (push) Successful in 16s
Some checks failed
Test before pr merge / test-lint (pull_request) Failing after 7s
Build on push / prepare (push) Successful in 11s
Build on push / core (push) Successful in 19s
Build on push / query (push) Successful in 20s
Build on push / cli (push) Successful in 19s
Build on push / dependency (push) Successful in 22s
Build on push / database (push) Successful in 16s
Build on push / translation (push) Successful in 16s
Build on push / mail (push) Successful in 17s
Build on push / application (push) Successful in 17s
Build on push / auth (push) Successful in 18s
Build on push / api (push) Successful in 16s
This commit is contained in:
@@ -12,7 +12,8 @@ from cpl.core.console import Console
|
|||||||
@click.command("init")
|
@click.command("init")
|
||||||
@click.argument("target", required=False)
|
@click.argument("target", required=False)
|
||||||
@click.argument("name", 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
|
workspace = None
|
||||||
project = None
|
project = None
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ def init(target: str, name: str):
|
|||||||
elif target in PROJECT_TYPES:
|
elif target in PROJECT_TYPES:
|
||||||
workspace = Structure.find_workspace_in_path(Path(name or "./").parent, with_parents=True)
|
workspace = Structure.find_workspace_in_path(Path(name or "./").parent, with_parents=True)
|
||||||
project = Structure.init_project(
|
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:
|
else:
|
||||||
Console.error(f"Unknown target '{target}'")
|
Console.error(f"Unknown target '{target}'")
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class Structure:
|
|||||||
return workspace
|
return workspace
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def init_project(rel_path: str, name: str, project_type: str, workspace: Workspace | None, verbose=False):
|
def init_project(rel_path: str, name: str, project_type: str, workspace: Workspace | None, install_deps=False, verbose=False):
|
||||||
if not Path(rel_path).exists():
|
if not Path(rel_path).exists():
|
||||||
rel_path = click.prompt("Project directory", type=click.Path(exists=True, file_okay=False), default="src")
|
rel_path = click.prompt("Project directory", type=click.Path(exists=True, file_okay=False), default="src")
|
||||||
|
|
||||||
@@ -139,16 +139,17 @@ class Structure:
|
|||||||
|
|
||||||
project.save()
|
project.save()
|
||||||
|
|
||||||
from cpl.cli.command.package.install import install
|
if install_deps:
|
||||||
|
from cpl.cli.command.package.install import install
|
||||||
|
|
||||||
old_cwd = os.getcwd()
|
old_cwd = os.getcwd()
|
||||||
os.chdir(Path(workspace.path).parent)
|
os.chdir(Path(workspace.path).parent)
|
||||||
install.callback(f"cpl-cli>={cli.__version__}", project.name, dev=True, verbose=verbose)
|
install.callback(f"cpl-cli>={cli.__version__}", project.name, dev=True, verbose=verbose)
|
||||||
if project_type in Structure._dependency_map:
|
if project_type in Structure._dependency_map:
|
||||||
for package in Structure._dependency_map[project_type]:
|
for package in Structure._dependency_map[project_type]:
|
||||||
install.callback(package, project.name, dev=False, verbose=verbose)
|
install.callback(package, project.name, dev=False, verbose=verbose)
|
||||||
|
|
||||||
os.chdir(old_cwd)
|
os.chdir(old_cwd)
|
||||||
|
|
||||||
if workspace is not None:
|
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))
|
||||||
@@ -199,4 +200,4 @@ class Structure:
|
|||||||
shutil.copy(src_file, tgt_file)
|
shutil.copy(src_file, tgt_file)
|
||||||
|
|
||||||
Console.write_line()
|
Console.write_line()
|
||||||
Structure.init_project(str(path), name, project_type, workspace)
|
Structure.init_project(str(path), name, project_type, workspace, install_deps=True, verbose=verbose)
|
||||||
|
|||||||
Reference in New Issue
Block a user