Example #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")
Example #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")
Example #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()
Example #4
0
def add(dependencies: List[Dependency]) -> None:
    """
    Add one or more pip packages.
    """
    venv.activate()
    sys_calls.run(["pip", "install"] + dependencies)
    _freeze_requirements()
Example #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()
Example #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")
Example #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")
Example #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"])
Example #9
0
def run() -> None:
    """
    Start frontend server normally.
    """
    try:
        sys_calls.run(["yarn", "start"], cwd="frontend/")
    except KeyboardInterrupt:
        pass
Example #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"])
Example #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])
Example #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])
Example #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"])
Example #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])
Example #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/')
Example #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
Example #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"])
Example #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"])
Example #19
0
def remove(files: List[File]) -> None:
    """
    Removes all specified files recursively.
    """
    sys_calls.run(["rm", "-rf"] + files)
Example #20
0
def install() -> None:
    """
    Downloads & installs all dependencies for the backend.
    """
    pipenv.create()
    sys_calls.run(["pipenv", "install", "--ignore-pipfile", "--dev"])
Example #21
0
def remove(dependencies: List[Dependency]) -> None:
    """
    Remove one or more pip packages.
    """
    sys_calls.run(["pipenv", "uninstall"] + dependencies)
Example #22
0
def upgrade(dependencies: List[Dependency]) -> None:
    """
    Upgrade one or more out-of-date pip packages.
    """
    sys_calls.run(["pipenv", "update"] + dependencies)
Example #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)
Example #24
0
def dependency_tree() -> None:
    """
    Visualize which dependencies depend upon which.
    """
    sys_calls.run(["pipenv", "graph"])
Example #25
0
def list_outdated() -> None:
    """
    List pip packages that should be updated.
    """
    sys_calls.run(["pipenv", "update", "--outdated"])
Example #26
0
def remove(files: List[File]) -> None:
    """
    Removes all specified files recursively.
    """
    sys_calls.run(['rm', '-rf'] + files)
Example #27
0
def add(files: List[str]) -> None:
    """
    Add given files / glob.
    """
    sys_calls.run(["git", "add"] + files)
Example #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
Example #29
0
def add_remote(remote: Remote, url: RemoteURL) -> None:
    """
    Add given remote to local git.
    """
    sys_calls.run(["git", "remote", "add", remote, url])
Example #30
0
def push(remote: Remote, remote_branch: Branch) -> None:
    """
    Push to given remote.
    """
    sys_calls.run(["git", "push", remote, remote_branch])