Beispiel #1
0
def setup():
    project_name: str = Node.get_full_response()["metadata"]["name"]
    if not Node.get_full_response()["github"]["use"]:
        bash(f"npx create-react-app {project_name}")
    else:
        github_username: str = Node.get_full_response(
        )["github_credentials"]["username"]
        github_auth: str = ""
        if "password" in Node.get_full_response()["github_credentials"]:
            github_auth = Node.get_full_response(
            )["github_credentials"]["password"]
        if "oauth_token" in Node.get_full_response()["github_credentials"]:
            github_auth = Node.get_full_response(
            )["github_credentials"]["oauth_token"]

        bash(f"cd {project_name} && npx create-react-app website")

        # gitignore_file_path: str = f"{os.getcwd()}/{project_name}/website/.gitignore"
        # append_file_to_file(gitignore_file_path, f"{os.getcwd()}/{project_name}/.gitignore")
        # delete_file(gitignore_file_path)

        commit_and_push(
            "Initialized React",
            project_name,
            github_username,
            github_auth,
            directory=project_name,
        )
Beispiel #2
0
def _setup():
    project_name: str = Node.get_full_response()["metadata"]["name"]

    bash(f"cd {project_name} && mkdir backend")
    # setup the virtual environment
    bash(f"cd {project_name}/backend && python -m venv {project_name}-env")

    gitignore_source: str = get_gitignore_file("python")
    append_text_to_file(gitignore_source, f"{os.getcwd()}/{project_name}/backend/.gitignore")
Beispiel #3
0
    def post_process(self, responses):
        if responses["use"] == True:
            frameworks: Dict[str, Any] = self.get_full_response()["framework"]
            project_name: str = self.get_full_response()["metadata"]["name"]
            bash(
                f"cd {project_name} && mkdir .github && cd .github && mkdir workflows"
            )

            for key, value in frameworks.items():
                call_hook("github_actions", key, value)
Beispiel #4
0
def setup():
    project_name: str = Node.get_full_response()["metadata"]["name"]
    # assert that vue is installed
    bash("sudo npm install -g vue")

    # assert the vue cli is installed
    bash("sudo npm install -g @vue/cli")

    if not Node.get_full_response()["github"]["use"]:
        bash(f"vue create -d {project_name}")
    else:
        github_username: str = Node.get_full_response(
        )["github_credentials"]["username"]
        github_auth: str = ""
        if "password" in Node.get_full_response()["github_credentials"]:
            github_auth = Node.get_full_response(
            )["github_credentials"]["password"]
        if "oauth_token" in Node.get_full_response()["github_credentials"]:
            github_auth = Node.get_full_response(
            )["github_credentials"]["oauth_token"]

        bash(f"cd {project_name} && vue create -d website")

        # gitignore_file_path: str = f"{os.getcwd()}/{project_name}/website/.gitignore"
        # append_file_to_file(gitignore_file_path, f"{os.getcwd()}/{project_name}/.gitignore")
        # delete_file(gitignore_file_path)

        commit_and_push(
            "Initialized Vue",
            project_name,
            github_username,
            github_auth,
            directory=project_name,
        )
Beispiel #5
0
def setup_module():
    _setup()

    project_name: str = Node.get_full_response()["metadata"]["name"]

    # backend/<project_name> directory
    bash(f"cd {project_name}/backend && mkdir {project_name}")
    bash(f'cd {project_name}/backend/{project_name} && echo "" > __init__.py')
    copy_file(
        f"{__assets_directory__}/python/module/__main__.py",
        f"{os.getcwd()}/{project_name}/backend/{project_name}/__main__.py",
    )

    _setup_devops()

    _commit("Initialized Python backend")
Beispiel #6
0
    def add_tool_version_as_attribute(self, tool_name: str) -> None:
        stdout = bash(f"{tool_name} -v")
        for line in stdout.splitlines():
            match = re.search(r"\d+\.\d+\.\d+", line.decode())

            if not match:
                print(
                    "Error " + tool_name +
                    " is not installed on this device. You can install node here https://nodejs.org/en/download/"
                )
                exit(0)
            else:
                self.add_attribute({tool_name: match.group(0)})
Beispiel #7
0
    def add_tool_version_as_attribute(self, tool_name: str, download_link: str,
                                      regex_str: str) -> None:
        stdout = bash(f"{tool_name} --version")
        for line in stdout.splitlines():
            match = re.search(regex_str, line.decode())

            if not match:
                raise EnvironmentError(
                    f"Error [{line.decode()}]{tool_name} is not installed on this device. You can install {tool_name} here {download_link}"
                )
            else:
                self.add_attribute({tool_name: match.group(0)})
                break
Beispiel #8
0
def _setup_devops():
    project_name: str = Node.get_full_response()["metadata"]["name"]
    version: str = Node.get_full_response()["metadata"]["version"]
    description: str = Node.get_full_response()["metadata"]["description"]
    author: str = Node.get_full_response()["metadata"]["owner"]
    email: str = Node.get_full_response()["metadata"]["owner_email"]
    project_license: str = Node.get_full_response()["metadata"]["license"]
    project_license = project_license[1:].partition("]")[0].upper()

    copy_file(
        f"{__assets_directory__}/python/devops/setup.py",
        f"{os.getcwd()}/{project_name}/backend/setup.py",
    )

    source: str = file_to_text(f"{os.getcwd()}/{project_name}/backend/setup.py")
    source = source.replace("__NAME__", project_name)
    source = source.replace("__VERSION__", version)
    source = source.replace("__DESCRIPTION__", description)
    source = source.replace("__AUTHOR__", author)
    source = source.replace("__EMAIL__", email)
    source = source.replace("__LICENSE__", project_license)

    text_to_file(source, f"{os.getcwd()}/{project_name}/backend/setup.py")

    copy_file(
        f"{__assets_directory__}/python/devops/noxfile.py",
        f"{os.getcwd()}/{project_name}/backend/noxfile.py",
    )

    # backend/tests directory
    bash(f"cd {project_name}/backend && mkdir tests")
    copy_file(
        f"{__assets_directory__}/python/devops/__test_util.py",
        f"{os.getcwd()}/{project_name}/backend/tests/test_util.py",
    )

    bash(f"cd {project_name}/backend && python -m pip install nox")
Beispiel #9
0
 def pre_process(self):
     project_name: str = self.get_full_response()["metadata"]["name"]
     github_username: str = self.get_full_response(
     )["github_credentials"]["username"]
     repo_download_url: str = f"https://github.com/{github_username}/{project_name}.git"
     bash(f"git clone {repo_download_url}")