Exemplo n.º 1
0
def remove(dependencies: List[Dependency]) -> None:
    """
    Remove one or more npm packages.
    """
    sys_calls.run(["yarn", "remove"] + dependencies, cwd="frontend/")
    add_type_stubs()
    git.remind_to_commit("package.json and yarn.lock")
Exemplo n.º 2
0
def add_dev(dependencies: List[Dependency]) -> None:
    """
    Add one or more pip packages to dev.
    """
    sys_calls.run(["yarn", "add", "--dev"] + dependencies, cwd="frontend/")
    add_type_stubs()
    git.remind_to_commit("package.json and yarn.lock")
Exemplo n.º 3
0
def remove(dependencies: List[Dependency]) -> None:
    """
    Remove one or more pip packages.
    """
    venv.activate()
    sys_calls.run(["pip-autoremove"] + dependencies + ['-y'])
    _freeze_requirements()
Exemplo n.º 4
0
def add(dependencies: List[Dependency]) -> None:
    """
    Add one or more pip packages.
    """
    venv.activate()
    sys_calls.run(["pip", "install"] + dependencies)
    _freeze_requirements()
Exemplo n.º 5
0
def upgrade(dependencies: List[Dependency]) -> None:
    """
    Upgrade one or more out-of-date pip packages.
    """
    venv.activate()
    sys_calls.run(["pip", "install", "--upgrade"] + dependencies)
    _freeze_requirements()
Exemplo n.º 6
0
def _freeze_requirements() -> None:
    """
    Updates the requirements.txt file with new dependencies.
    """
    with open('requirements.txt', 'w') as requirements:
        sys_calls.run(['pip', 'freeze'], stdout=requirements)
    git.remind_to_commit("requirements.txt")
Exemplo n.º 7
0
def upgrade(dependencies: List[Dependency]) -> None:
    """
    Upgrade one or more out-of-date npm packages.
    """
    sys_calls.run(["yarn", "upgrade"] + dependencies, cwd="frontend/")
    add_type_stubs()
    git.remind_to_commit("package.json and yarn.lock")
Exemplo n.º 8
0
def check_types() -> None:
    """
    Calls MyPy to check for type errors.
    """
    venv.activate()
    sys_calls.run(["mypy", "--strict-optional", "--ignore-missing-imports",
                   "--package", "scripts"])
Exemplo n.º 9
0
def run() -> None:
    """
    Start frontend server normally.
    """
    try:
        sys_calls.run(["yarn", "start"], cwd="frontend/")
    except KeyboardInterrupt:
        pass
Exemplo n.º 10
0
def install() -> None:
    """
    Downloads & installs all dependencies for the backend.
    """
    venv.create()
    venv.activate()
    sys_calls.run(["pip", "install", "--upgrade", 'pip', 'setuptools'])
    sys_calls.run(["pip", "install", "-r", "requirements.txt"])
Exemplo n.º 11
0
def commit(message: str) -> None:
    """
    Commit with message.
    """
    if sys_calls.is_windows_environment():
        # Windows must wrap message with "" because of how bash expansion works
        message = f'"{message}"'
    sys_calls.run(["git", "commit", "-m", message])
Exemplo n.º 12
0
def kill_process(pid: PID) -> None:
    """
    Kills the specified PID.
    """
    if sys_calls.is_windows_environment():
        command = ["taskkill", "/F", "/PID"]
    else:
        command = ["kill"]
    sys_calls.run(command + [pid])
Exemplo n.º 13
0
def create() -> None:
    """
    Create new Pipenv virtual environment in root if not already done.
    """
    if files.do_exist([".venv/"]):
        print("Pipenv already created.")
        return
    sys_calls.export("PIPENV_VENV_IN_PROJECT", "true")
    sys_calls.run(["pipenv", "--python", "3.7"])
Exemplo n.º 14
0
def kill_process(pid: PID) -> None:
    """
    Kills the specified PID.
    """
    if sys_calls.is_windows_environment():
        command = ['taskkill', '/F', '/PID']
    else:
        command = ['kill']
    sys_calls.run(command + [pid])
Exemplo n.º 15
0
def test() -> None:
    """
    Run unit tests.
    """
    venv.activate()
    if sys_calls.is_windows_environment():
        py = 'python'
    else:
        py = 'python3'
    sys_calls.run([py, '-m', 'unittest', 'discover', 'tests'], cwd='backend/')
Exemplo n.º 16
0
def run() -> None:
    """
    Start backend server normally.
    """
    venv.activate()
    os.environ['FLASK_APP'] = 'backend/src/app.py'
    try:
        sys_calls.run(["flask", "run"])
    except KeyboardInterrupt:
        pass
Exemplo n.º 17
0
def catchup() -> None:
    """
    Check server for changes, and install new dependencies if necessary.
    """
    if not git.is_clean_local():
        raise SystemExit('Must first commit your changes before catching up.')
    old_hash = git.get_file_hash('frontend/package.json')
    git.fast_forward('origin', git.get_current_branch())
    new_hash = git.get_file_hash('frontend/package.json')
    if old_hash != new_hash:
        sys_calls.run(["yarn", "install"])
Exemplo n.º 18
0
def catchup() -> None:
    """
    Check server for changes, and install new dependencies if necessary.
    """
    if not git.is_clean_local():
        raise SystemExit('Must first commit your changes before catching up.')
    old_hash = git.get_file_hash('requirements.txt')
    git.fast_forward('origin', git.get_current_branch())
    new_hash = git.get_file_hash('requirements.txt')
    if old_hash != new_hash:
        venv.activate()
        sys_calls.run(["pip", "install", "-r", "requirements.txt"])
Exemplo n.º 19
0
def remove(files: List[File]) -> None:
    """
    Removes all specified files recursively.
    """
    sys_calls.run(["rm", "-rf"] + files)
Exemplo n.º 20
0
def install() -> None:
    """
    Downloads & installs all dependencies for the backend.
    """
    pipenv.create()
    sys_calls.run(["pipenv", "install", "--ignore-pipfile", "--dev"])
Exemplo n.º 21
0
def remove(dependencies: List[Dependency]) -> None:
    """
    Remove one or more pip packages.
    """
    sys_calls.run(["pipenv", "uninstall"] + dependencies)
Exemplo n.º 22
0
def upgrade(dependencies: List[Dependency]) -> None:
    """
    Upgrade one or more out-of-date pip packages.
    """
    sys_calls.run(["pipenv", "update"] + dependencies)
Exemplo n.º 23
0
def add_dev(dependencies: List[Dependency]) -> None:
    """
    Add one or more pip packages to dev.
    """
    sys_calls.run(["pipenv", "install", "--dev", "--keep-outdated"] +
                  dependencies)
Exemplo n.º 24
0
def dependency_tree() -> None:
    """
    Visualize which dependencies depend upon which.
    """
    sys_calls.run(["pipenv", "graph"])
Exemplo n.º 25
0
def list_outdated() -> None:
    """
    List pip packages that should be updated.
    """
    sys_calls.run(["pipenv", "update", "--outdated"])
Exemplo n.º 26
0
def remove(files: List[File]) -> None:
    """
    Removes all specified files recursively.
    """
    sys_calls.run(['rm', '-rf'] + files)
Exemplo n.º 27
0
def add(files: List[str]) -> None:
    """
    Add given files / glob.
    """
    sys_calls.run(["git", "add"] + files)
Exemplo n.º 28
0
def is_clean_local() -> bool:
    """
    Returns True if there are no differences on local that need to be committed.
    """
    response = sys_calls.run(["git", "diff-index", "--quiet", "HEAD", "--"])
    return response.returncode == 0
Exemplo n.º 29
0
def add_remote(remote: Remote, url: RemoteURL) -> None:
    """
    Add given remote to local git.
    """
    sys_calls.run(["git", "remote", "add", remote, url])
Exemplo n.º 30
0
def push(remote: Remote, remote_branch: Branch) -> None:
    """
    Push to given remote.
    """
    sys_calls.run(["git", "push", remote, remote_branch])