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")
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")
def remove(dependencies: List[Dependency]) -> None: """ Remove one or more pip packages. """ venv.activate() sys_calls.run(["pip-autoremove"] + dependencies + ['-y']) _freeze_requirements()
def add(dependencies: List[Dependency]) -> None: """ Add one or more pip packages. """ venv.activate() sys_calls.run(["pip", "install"] + dependencies) _freeze_requirements()
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()
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")
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")
def check_types() -> None: """ Calls MyPy to check for type errors. """ venv.activate() sys_calls.run(["mypy", "--strict-optional", "--ignore-missing-imports", "--package", "scripts"])
def run() -> None: """ Start frontend server normally. """ try: sys_calls.run(["yarn", "start"], cwd="frontend/") except KeyboardInterrupt: pass
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"])
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])
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])
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"])
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])
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/')
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
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"])
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"])
def remove(files: List[File]) -> None: """ Removes all specified files recursively. """ sys_calls.run(["rm", "-rf"] + files)
def install() -> None: """ Downloads & installs all dependencies for the backend. """ pipenv.create() sys_calls.run(["pipenv", "install", "--ignore-pipfile", "--dev"])
def remove(dependencies: List[Dependency]) -> None: """ Remove one or more pip packages. """ sys_calls.run(["pipenv", "uninstall"] + dependencies)
def upgrade(dependencies: List[Dependency]) -> None: """ Upgrade one or more out-of-date pip packages. """ sys_calls.run(["pipenv", "update"] + dependencies)
def add_dev(dependencies: List[Dependency]) -> None: """ Add one or more pip packages to dev. """ sys_calls.run(["pipenv", "install", "--dev", "--keep-outdated"] + dependencies)
def dependency_tree() -> None: """ Visualize which dependencies depend upon which. """ sys_calls.run(["pipenv", "graph"])
def list_outdated() -> None: """ List pip packages that should be updated. """ sys_calls.run(["pipenv", "update", "--outdated"])
def remove(files: List[File]) -> None: """ Removes all specified files recursively. """ sys_calls.run(['rm', '-rf'] + files)
def add(files: List[str]) -> None: """ Add given files / glob. """ sys_calls.run(["git", "add"] + files)
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
def add_remote(remote: Remote, url: RemoteURL) -> None: """ Add given remote to local git. """ sys_calls.run(["git", "remote", "add", remote, url])
def push(remote: Remote, remote_branch: Branch) -> None: """ Push to given remote. """ sys_calls.run(["git", "push", remote, remote_branch])