def process_common_operations(
            self,
            path: Path,
            skip_common_files=False,
            skip_fix_underline=False,
            domain: Optional[str] = None,
            subdomain: Union[str, bool] = None,
            language: Union[str, bool] = None,
            dot_cookietemple: Optional[dict] = None) -> None:
        """
        Create all stuff that is common for cookietemples template creation process; in detail those things are:
        create and copy common files, fix docs style, lint the project and ask whether the user wants to create a github repo.
        """
        # create the common files and copy them into the templates directory (skip if flag is set)

        if not skip_common_files:
            self.create_common_files()

        self.create_dot_cookietemple(
            template_version=self.creator_ctx.template_version)

        if self.creator_ctx.language == 'python':
            project_path = f'{self.CWD}/{self.creator_ctx.project_slug.replace("-", "_")}'
        else:
            project_path = f'{self.CWD}/{self.creator_ctx.project_slug}'

        # Ensure that docs are looking good (skip if flag is set)
        if not skip_fix_underline:
            fix_short_title_underline(f'{project_path}/docs/index.rst')

        # Lint the project to verify that the new template adheres to all standards
        lint_project(project_path, is_create=True, skip_external=False)

        if self.creator_ctx.is_github_repo and not dot_cookietemple:
            # rename the currently created template to a temporary name, create Github repo, push, remove temporary template
            tmp_project_path = f'{project_path}_cookietemple_tmp'
            os.mkdir(tmp_project_path)
            create_push_github_repository(project_path, self.creator_ctx,
                                          tmp_project_path)
            shutil.rmtree(tmp_project_path, ignore_errors=True)

        if subdomain:
            console.print()
            console.print(
                '[bold blue]Please visit: https://cookietemple.readthedocs.io/en/latest/available_templates/available_templates.html'
                f'#{domain}-{subdomain}-{language} for more information about how to use your chosen template.'
            )
        else:
            console.print()
            console.print(
                '[bold blue]Please visit: https://cookietemple.readthedocs.io/en/latest/available_templates/available_templates.html'
                f'#{domain}-{language} for more information about how to use your chosen template.'
            )

        # do not move if path is current working directory or a directory named like the project in the current working directory (second is default case)
        if path != self.CWD and path != Path(
                self.CWD / self.creator_ctx.project_slug_no_hyphen):
            shutil.move(
                f'{self.CWD}/{self.creator_ctx.project_slug_no_hyphen}',
                f'{path}/{self.creator_ctx.project_slug_no_hyphen}')
Example #2
0
def lint(project_dir, skip_external) -> None:
    """
    Lint your existing cookietemple project.

    Verify that your existing project still adheres to cookietemple's standards.
    cookietemple runs several general linting functions, which all templates share.
    Examples include a consistent project version, the existence of documentation and whether cookiecutter statements are still left.
    Afterwards, template specific linting is invoked. cli-python for example may check for the existence of a setup.py file.
    Both results are collected and displayed.
    """
    lint_project(project_dir, skip_external)