-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
109 lines (88 loc) · 3.67 KB
/
Makefile
File metadata and controls
109 lines (88 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Build one browser package
define BUILD_EXTENSION
@echo ""
@echo "---------------------------------------"
@echo "---- $(1)"
@echo "---------------------------------------"
## Copy the appropriate manifest file
@cd ./angular && \
echo "Using manifest_$(1).json" && \
cp ./src/manifest_$(1).json ./src/manifest.json
## Build the Angular app in production mode
@cd ./angular && npm run build:prod
## Build the web extension package
@cd ./angular && npx web-ext build -s ./dist -o
## Extract version from manifest
@cd ./angular && VERSION=$$(jq -r '.version' ./src/manifest.json)
## Rename the zip file based on browser type
@cd ./angular/web-ext-artifacts/ && mv mist_extension-$$VERSION.zip mist_extension-$(1)-$$VERSION.zip
## Remove any existing directory
@cd ./angular/web-ext-artifacts/ && rm -rf mist_extension-$(1)
## Unzip the package into a directory
@cd ./angular/web-ext-artifacts/ && unzip -q mist_extension-$(1)-$$VERSION.zip -d mist_extension-$(1)
endef
.PHONY: help init-openapi init-angular init update-openapi run build webext-ffx webext-chrome webext-all
# Use bash as shell
SHELL := /bin/bash
# Project name (from top-level directory name)
PROJECT_NAME ?= $(shell basename $(CURDIR))
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
init-openapi: ## Initialize or update OpenAPI submodule
@if [ ! -d "mist_openapi/.git" ]; then \
echo "Initializing OpenAPI submodule..."; \
git submodule update --init mist_openapi; \
fi
@echo "Updating OpenAPI submodule..."; \
git submodule update --remote mist_openapi
init-angular: ## Initialize Angular project
@if [ ! -d "./angular/node_modules" ]; then \
echo "Installing Angular dependencies..."; \
npm install --prefix ./angular; \
fi
@echo "Building Angular project..."; \
npm run build --prefix ./angular
init: init-openapi init-angular ## Initialize the project
update-openapi: init-openapi ## Update OpenAPI submodule
@echo "Generating code from OpenAPI spec..."
@python3 ./scripts/oas_converter.py
run: ## Run the Angular application
@if [ ! -d "./angular/node_modules" ]; then \
echo "Angular dependencies not installed. Run 'make init-angular' first."; \
exit 1; \
fi
@echo "Starting Angular application..."
npm start --prefix ./angular
update-version: ## Update the version in package.json and manifest.json
@if [ -z "$(VERSION)" ]; then \
echo "Error: VERSION variable is required. Usage: make update-version VERSION=x.y.z"; \
exit 1; \
fi
@echo "Updating version to $(VERSION)..."
@sed -i '' 's/"version": "[^"]*"/"version": "$(VERSION)"/' ./angular/package.json
@sed -i '' 's/"version": "[^"]*"/"version": "$(VERSION)"/' ./angular/src/manifest_ffx.json
@sed -i '' 's/"version": "[^"]*"/"version": "$(VERSION)"/' ./angular/src/manifest_chrome.json
@echo "Version updated to $(VERSION)."
webext-ffx: ## Build the Firefox web extension package
@echo "Building Firefox web extension package..."
$(call BUILD_EXTENSION,ffx)
webext-chrome: ## Build the Chrome web extension package
@echo "Building Chrome web extension package..."
$(call BUILD_EXTENSION,chrome)
webext-all: webext-ffx webext-chrome ## Build all web extension packages
build: ## Build the project
@if [ -z "$(VERSION)" ]; then \
echo "Error: VERSION variable is required. Usage: make build VERSION=x.y.z"; \
exit 1; \
fi
@echo "Building project..."
${MAKE} update-version VERSION=$(VERSION)
@if [ ! -d "./angular/node_modules" ]; then \
echo "Installing Angular dependencies..."; \
npm install --prefix ./angular; \
fi
${MAKE} update-openapi
$(MAKE) webext-all