refactor: update Makefile commands for improved readability and efficiency (#3596)
* chore(Makefile): redirect output of 'poetry install' and 'npm install' commands to /dev/null to reduce noise chore(Makefile): redirect output of 'npm run build' command to /dev/null to improve build process efficiency feat(Makefile): update build_frontend target to include copying built files to backend directory for deployment * chore(Makefile): refactor lint target to depend on install_backend task for better dependency management chore(Makefile): refactor frontend, frontendc, backend, build_and_run, build_and_install, and build targets to depend on setup_env task for consistent environment setup before execution * chore(Makefile): update Makefile commands to use @ symbol for silent execution and improve readability * chore(Makefile): update Makefile commands to use "@" to suppress command output and improve readability * chore(Makefile): update run_cli target to include dependencies installation and frontend build steps for better clarity and consistency * chore(Makefile): add command to delete empty directories in clean_python_cache target
This commit is contained in:
parent
9ae4e29815
commit
5d81e8dce6
1 changed files with 30 additions and 42 deletions
72
Makefile
72
Makefile
|
|
@ -63,23 +63,24 @@ help: ## show this help message
|
|||
|
||||
install_backend: ## install the backend dependencies
|
||||
@echo 'Installing backend dependencies'
|
||||
@poetry install
|
||||
@poetry install > /dev/null 2>&1
|
||||
|
||||
install_frontend: ## install the frontend dependencies
|
||||
@echo 'Installing frontend dependencies'
|
||||
cd src/frontend && npm install
|
||||
@cd src/frontend && npm install > /dev/null 2>&1
|
||||
|
||||
build_frontend: ## build the frontend static files
|
||||
cd src/frontend && CI='' npm run build
|
||||
rm -rf src/backend/base/langflow/frontend
|
||||
cp -r src/frontend/build src/backend/base/langflow/frontend
|
||||
@echo 'Building frontend static files'
|
||||
@cd src/frontend && CI='' npm run build > /dev/null 2>&1
|
||||
@rm -rf src/backend/base/langflow/frontend
|
||||
@cp -r src/frontend/build src/backend/base/langflow/frontend
|
||||
|
||||
init: check_tools clean_python_cache clean_npm_cache ## initialize the project
|
||||
make install_backend
|
||||
make install_frontend
|
||||
make build_frontend
|
||||
@make install_backend
|
||||
@make install_frontend
|
||||
@make build_frontend
|
||||
@echo "$(GREEN)All requirements are installed.$(NC)"
|
||||
python -m langflow run
|
||||
@python -m langflow run
|
||||
|
||||
######################
|
||||
# CLEAN PROJECT
|
||||
|
|
@ -91,6 +92,7 @@ clean_python_cache:
|
|||
find . -type f -name '*.py[cod]' -exec rm -f {} +
|
||||
find . -type f -name '*~' -exec rm -f {} +
|
||||
find . -type f -name '.*~' -exec rm -f {} +
|
||||
find . -type d -empty -delete
|
||||
@echo "$(GREEN)Python cache cleaned.$(NC)"
|
||||
|
||||
clean_npm_cache:
|
||||
|
|
@ -108,15 +110,15 @@ setup_poetry: ## install poetry using pipx
|
|||
add:
|
||||
@echo 'Adding dependencies'
|
||||
ifdef devel
|
||||
cd src/backend/base && poetry add --group dev $(devel)
|
||||
@cd src/backend/base && poetry add --group dev $(devel)
|
||||
endif
|
||||
|
||||
ifdef main
|
||||
poetry add $(main)
|
||||
@poetry add $(main)
|
||||
endif
|
||||
|
||||
ifdef base
|
||||
cd src/backend/base && poetry add $(base)
|
||||
@cd src/backend/base && poetry add $(base)
|
||||
endif
|
||||
|
||||
|
||||
|
|
@ -172,37 +174,32 @@ fix_codespell: ## run codespell to fix spelling errors
|
|||
poetry run codespell --toml pyproject.toml --write
|
||||
|
||||
format: ## run code formatters
|
||||
poetry run ruff check . --fix
|
||||
poetry run ruff format .
|
||||
cd src/frontend && npm run format
|
||||
@poetry run ruff check . --fix
|
||||
@poetry run ruff format .
|
||||
@cd src/frontend && npm run format
|
||||
|
||||
lint: ## run linters
|
||||
poetry run mypy --namespace-packages -p "langflow"
|
||||
lint: install_backend ## run linters
|
||||
@poetry run mypy --namespace-packages -p "langflow"
|
||||
|
||||
install_frontendci:
|
||||
cd src/frontend && npm ci
|
||||
@cd src/frontend && npm ci > /dev/null 2>&1
|
||||
|
||||
install_frontendc:
|
||||
cd src/frontend && rm -rf node_modules package-lock.json && npm install
|
||||
@cd src/frontend && rm -rf node_modules package-lock.json && npm install > /dev/null 2>&1
|
||||
|
||||
run_frontend: ## run the frontend
|
||||
@-kill -9 `lsof -t -i:3000`
|
||||
cd src/frontend && npm start
|
||||
@cd src/frontend && npm start
|
||||
|
||||
tests_frontend: ## run frontend tests
|
||||
ifeq ($(UI), true)
|
||||
cd src/frontend && npx playwright test --ui --project=chromium
|
||||
@cd src/frontend && npx playwright test --ui --project=chromium
|
||||
else
|
||||
cd src/frontend && npx playwright test --project=chromium
|
||||
@cd src/frontend && npx playwright test --project=chromium
|
||||
endif
|
||||
|
||||
run_cli:
|
||||
run_cli: install_frontend install_backend build_frontend ## run the CLI
|
||||
@echo 'Running the CLI'
|
||||
@make install_frontend > /dev/null
|
||||
@echo 'Install backend dependencies'
|
||||
@make install_backend > /dev/null
|
||||
@echo 'Building the frontend'
|
||||
@make build_frontend > /dev/null
|
||||
ifdef env
|
||||
@make start env=$(env) host=$(host) port=$(port) log_level=$(log_level)
|
||||
else
|
||||
|
|
@ -251,20 +248,15 @@ setup_devcontainer: ## set up the development container
|
|||
setup_env: ## set up the environment
|
||||
@sh ./scripts/setup/setup_env.sh
|
||||
|
||||
frontend: ## run the frontend in development mode
|
||||
make install_frontend
|
||||
frontend: install_frontend ## run the frontend in development mode
|
||||
make run_frontend
|
||||
|
||||
frontendc:
|
||||
make install_frontendc
|
||||
frontendc: install_frontendc
|
||||
make run_frontend
|
||||
|
||||
|
||||
|
||||
backend: ## run the backend in development mode
|
||||
@echo 'Setting up the environment'
|
||||
@make setup_env
|
||||
make install_backend
|
||||
backend: setup_env install_backend ## run the backend in development mode
|
||||
@-kill -9 $$(lsof -t -i:7860)
|
||||
ifdef login
|
||||
@echo "Running backend autologin is $(login)";
|
||||
|
|
@ -288,9 +280,7 @@ else
|
|||
--workers $(workers)
|
||||
endif
|
||||
|
||||
build_and_run: ## build the project and run it
|
||||
@echo 'Removing dist folder'
|
||||
@make setup_env
|
||||
build_and_run: setup_env ## build the project and run it
|
||||
rm -rf dist
|
||||
rm -rf src/backend/base/dist
|
||||
make build
|
||||
|
|
@ -303,9 +293,7 @@ build_and_install: ## build the project and install it
|
|||
rm -rf src/backend/base/dist
|
||||
make build && poetry run pip install dist/*.whl && pip install src/backend/base/dist/*.whl --force-reinstall
|
||||
|
||||
build: ## build the frontend static files and package the project
|
||||
@echo 'Building the project'
|
||||
@make setup_env
|
||||
build: setup_env ## build the frontend static files and package the project
|
||||
ifdef base
|
||||
make install_frontendci
|
||||
make build_frontend
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue