Skip to content

Commit d5459d0

Browse files
Scope nvm Node.js installation to dev Make targets only (#974)
1 parent 29328bc commit d5459d0

File tree

10 files changed

+432
-448
lines changed

10 files changed

+432
-448
lines changed

browser/Makefile

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,62 @@
1-
.PHONY: clean install build start dev dev-watch schema help
1+
.PHONY: all help clean nvm-install-node install-dependencies install-playwright install build-server build start-service start dev dev-watch smoke-simulation schema
22

33
# Environment variables
44
export PLAYWRIGHT_BROWSERS_PATH ?= 0
55
BIN := ./node_modules/.bin
66

7+
all: build
8+
9+
help: ## Show available targets
10+
@awk 'BEGIN {FS = ":.*## "}; /^[a-zA-Z0-9_.-]+:.*## / {printf "%-24s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
11+
12+
clean: ## Clean build artifacts, node_modules, and other cache files
13+
@echo "Cleaning build artifacts, node_modules, and test results of LTBrowser app"
14+
rm -rf dist
15+
rm -rf node_modules
16+
rm -rf e2e_results
17+
rm -rf .cache
18+
rm -rf screenshots
19+
720
# Sets Node.js version from .nvmrc via nvm if it is installed, otherwise falls back to system Node
8-
nvm_install_node = if [ -s "$$NVM_DIR/nvm.sh" ]; then . "$$NVM_DIR/nvm.sh" && nvm install; fi
21+
nvm-install-node:
22+
@if [ -s "$$NVM_DIR/nvm.sh" ]; then . "$$NVM_DIR/nvm.sh" && nvm install; fi
923

1024
install-dependencies:
1125
@echo "Installing node_modules of LTBrowser app"
12-
@$(nvm_install_node) && npm install
26+
@npm install
1327
@echo "Successfully installed node_modules of LTBrowser app"
1428

1529
install-playwright: install-dependencies
1630
@echo "Installing Playwright Chromium browser of LTBrowser app"
1731
$(BIN)/playwright install --with-deps chromium
1832
@echo "Successfully installed Playwright Chromium browser of LTBrowser app"
1933

20-
## Install npm dependencies and Playwright Chromium browser with its dependencies
21-
install: install-dependencies install-playwright
22-
23-
## Clean build artifacts, node_modules, and test results
24-
clean:
25-
@echo "Cleaning build artifacts, node_modules, and test results of LTBrowser app"
26-
rm -rf dist
27-
rm -rf node_modules
28-
rm -rf e2e_results
29-
rm -rf .cache
30-
rm -rf screenshots
34+
install: install-dependencies install-playwright ## Installs the dependencies and Playwright Chromium browser with its dependencies
3135

3236
build-server:
3337
@echo "Building LTBrowser app"
34-
@$(nvm_install_node) && $(BIN)/tsc
38+
@$(BIN)/tsc
3539
@echo "LTBrowser app built successfully"
3640

37-
## Builds the LTBrowser server, by first installing the dependencies and then building the server. This does not install the Playwright browser which should be done separately
38-
build: clean install-dependencies build-server
41+
build: clean install-dependencies build-server ## Builds the LTBrowser server by first installing the dependencies and then building the server
3942

40-
## Used by service to start the LTBrowser server in linux environments
41-
start-service: install
43+
start-service: install ## Used by service to start the LTBrowser server in linux environments
4244
@echo "Starting LTBrowser app service"
4345
node dist/server.js
4446

45-
## Start the LTBrowser server by first doing a cleanup and then performing a production mode build
46-
start: build install-playwright
47+
start: build install-playwright ## Start the LTBrowser server by first doing a cleanup and then performing a production mode build
4748
@echo "Starting LTBrowser app"
4849
node dist/server.js
4950

50-
## Start the LTBrowser server in development mode
51-
dev: install
51+
dev: nvm-install-node install ## Start the LTBrowser server in development mode
5252
@echo "Starting LTBrowser app in development mode"
5353
$(BIN)/tsx src/server.ts
5454

55-
## Start the LTBrowser server in development watch mode
56-
dev-watch: install
55+
dev-watch: nvm-install-node install ## Start the LTBrowser server in development watch mode
5756
@echo "Starting LTBrowser app in development watch mode"
5857
$(BIN)/tsx watch src/server.ts
5958

60-
## Run the smoke simulations
61-
smoke-simulation: install
59+
smoke-simulation: nvm-install-node install ## Run the smoke simulations
6260
@if [ -f "src/smoke_simulations/smoke_simulation.json" ]; then \
6361
echo "Running smoke simulation of LTBrowser app"; \
6462
else \
@@ -75,14 +73,8 @@ smoke-simulation: install
7573
exit 1; \
7674
fi
7775

78-
## Generate the OpenAPI schemas for the API in JSON and YAML format
79-
schema:
76+
schema: ## Generate the OpenAPI schemas for the API in JSON and YAML format
8077
@echo "Generating OpenAPI schema in JSON format"
8178
NODE_OPTIONS='--import=tsx/esm' $(BIN)/fastify generate-swagger src/app.ts > ./openapi.json
8279
@echo "Generating OpenAPI schema in YAML format"
8380
NODE_OPTIONS='--import=tsx/esm' $(BIN)/fastify generate-swagger --yaml=true src/app.ts > ./openapi.yaml
84-
85-
## Shows the list of available commands
86-
help:
87-
@awk '/^##/{c=substr($$0,3); getline; if($$1 ~ /^[a-zA-Z_-]+:/) printf "\033[36m%-15s\033[0m %s\n", $$1, c}' ./Makefile | sort
88-
@echo

0 commit comments

Comments
 (0)