diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 6f248d77..59087226 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.4.5 +current_version = 0.4.6 commit = True tag = True diff --git a/flybirds/cli/__main__.py b/flybirds/cli/__main__.py index 1c32edb6..c926f101 100644 --- a/flybirds/cli/__main__.py +++ b/flybirds/cli/__main__.py @@ -7,7 +7,7 @@ import typer import flybirds.utils.flybirds_log as log -from flybirds.cli.create_project import create_demo +from flybirds.cli.create_project import create_demo, create_mini from flybirds.cli.parse_args import parse_args, default_report_path from flybirds.core.launch_cycle.run_manage import run_script @@ -82,11 +82,22 @@ def runner( @app.command("create") -def create_project(): +def create_project( + mini: bool = typer.Option( + None, + "--mini", + "-M", + help="create mini project", + ) + +): """ Generate project example """ - create_demo() + if mini is not None: + create_mini() + else: + create_demo() if __name__ == "__main__": diff --git a/flybirds/cli/create_project.py b/flybirds/cli/create_project.py index 0a584437..8f723414 100644 --- a/flybirds/cli/create_project.py +++ b/flybirds/cli/create_project.py @@ -39,7 +39,7 @@ def create_demo(): p_message = platform_start + platform_ending test_platform = typer.prompt(p_message) if test_platform is None or test_platform.strip().lower() not in [ - 'android', 'ios', 'web']: + 'android', 'ios', 'web']: test_platform = 'android' test_platform = test_platform.strip().lower() user_dict['test_platform'] = test_platform @@ -128,22 +128,73 @@ def create_demo(): ) -def copy_from_template(progress, user_dict): +def create_mini(): + """ + Create mini project cli + """ + user_dict = {} + + try: + typer.echo(f"Cloning into ...") + total = 900 + with typer.progressbar(length=total, label="Processing") as progress: + demo_path = copy_from_template(progress, user_dict, os.path.normpath(os.getcwd())) + compare_path = os.path.join(demo_path, "compareData") + feat_files = get_files_from_dir(compare_path) + + config_ele = os.path.join(demo_path, "config/ele_locator.json") + feat_files.append(config_ele) + + config_schema = os.path.join(demo_path, "config/schema_url.json") + feat_files.append(config_schema) + + config_flybirds = os.path.join(demo_path, "config/flybirds_config.json") + feat_files.append(config_flybirds) + + interface_path = os.path.join(demo_path, "interfaceIgnoreConfig/test.json") + feat_files.append(interface_path) + + mock_path = os.path.join(demo_path, "mockCaseData/mock_test.json") + feat_files.append(mock_path) + + for file in feat_files: + os.remove(file) + + feature_path = os.path.join(demo_path, "features/test") + shutil.rmtree(feature_path) + + typer.secho( + f"Done it! Create Project has success!\n" + f"You can find it at: {demo_path}", + fg=typer.colors.MAGENTA, + ) + except Exception as e: + typer.secho( + f"Error!! create project has error, errMsg: {e}", + fg=typer.colors.MAGENTA, + err=True, + ) + + +def copy_from_template(progress, user_dict, target=None): """ Generate project files from template """ # Serialization path src_file_path = template.__file__ src_path = os.path.normpath(src_file_path[0: src_file_path.rfind(os.sep)]) - target_path = os.path.normpath( - os.path.join(os.path.normpath(os.getcwd()), - user_dict.get('project_name')) - ) + if target is None: + target_path = os.path.normpath( + os.path.join(os.path.normpath(os.getcwd()), + user_dict.get('project_name')) + ) + if os.path.isdir(target_path): + # target_path is existed + shutil.rmtree(target_path) + else: + target_path = target - if os.path.isdir(target_path): - # target_path is existed - shutil.rmtree(target_path) - shutil.copytree(src_path, target_path) + shutil.copytree(src_path, target_path, dirs_exist_ok=True) progress.update(100) try: @@ -179,7 +230,6 @@ def copy_from_template(progress, user_dict): # modify packageName package_name = user_dict.get('package_name') - package_name = user_dict.get('package_name') if package_name is not None: replace_file_content( os.path.join(target_path, "config/flybirds_config.json"), diff --git a/flybirds/core/plugin/plugins/default/step/app.py b/flybirds/core/plugin/plugins/default/step/app.py index 3d68f71d..29f26af3 100644 --- a/flybirds/core/plugin/plugins/default/step/app.py +++ b/flybirds/core/plugin/plugins/default/step/app.py @@ -37,7 +37,7 @@ def start_app(context, param): g_Context.app.wake_app(param, 10) gr.set_value("packageName", param) # Modal box error detection - poco_ele.detect_error() + # poco_ele.detect_error() def restart_app(context): diff --git a/requirements.txt b/requirements.txt index dc6014bc..a3d54b81 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ airtest>=1.2.6 setuptools>=47.1.0 behave==1.2.6 jsonpath==0.82 -typer>=0.4.0 +typer>=0.6.0 tidevice==0.5.9 pyasn1==0.4.8 pyOpenSSL==19.1.0 @@ -17,3 +17,4 @@ paddlepaddle>=2.3.0 protobuf==3.20.1 baseImage>=2.1.1 ffmpeg-python>=0.2.0 +rich<13.0.0,>=10.11.0 diff --git a/setup.py b/setup.py index 755aecba..3e8b4206 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ def parse_requirements(filename): setup( name="flybirds", - version="0.4.5", + version="0.4.6", author="trip_flight", author_email="flybirds_support@trip.com", description="BDD-driven natural language automated testing framework",