Skip to content

Commit c435212

Browse files
committed
create Makefile
1 parent 61720ff commit c435212

6 files changed

Lines changed: 112 additions & 52 deletions

File tree

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "mist_openapi"]
2+
path = mist_openapi
3+
url = https://github.com/Mist-Automation-Programmability/mist_openapi.git

00_generate.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

1_gen_api_struct.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

2_build.sh

Lines changed: 0 additions & 42 deletions
This file was deleted.

Makefile

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

0 commit comments

Comments
 (0)