1
+ # Makefile for Markdown Arweave Uploader
2
+
3
+ # Detect OS
4
+ ifeq ($(OS ) ,Windows_NT)
5
+ DETECTED_OS := Windows
6
+ else
7
+ DETECTED_OS := $(shell uname -s)
8
+ endif
9
+
10
+ # Tool management
11
+ NODE := node
12
+ NPM := npm
13
+ VSCE := npx vsce
14
+
15
+ # Colors
16
+ YELLOW := \033[1;33m
17
+ GREEN := \033[1;32m
18
+ RED := \033[1;31m
19
+ BLUE := \033[1;34m
20
+ RESET := \033[0m
21
+
22
+ # Targets
23
+ .PHONY : all setup setup-first deps clean clean-all dev build package publish check \
24
+ env-setup env-create env-check release-patch release-minor release-major help
25
+
26
+ all : setup build
27
+
28
+ # Setup commands
29
+ setup : deps node_modules env-check_silent
30
+ @echo " $( BLUE) Checking if environment is properly set up...$( RESET) "
31
+ @if [ ! -f .env ]; then \
32
+ echo " $( YELLOW) No .env file found. Creating from template...$( RESET) " ; \
33
+ $(MAKE ) env-create; \
34
+ echo " $( YELLOW) Please edit the .env file with your settings!$( RESET) " ; \
35
+ fi
36
+ @echo " $( GREEN) ✓ Setup complete$( RESET) "
37
+ @echo " $( YELLOW) Run 'make env-setup' if you need to configure environment variables$( RESET) "
38
+
39
+ # Check environment without verbose output (for use in other targets)
40
+ env-check_silent :
41
+ @$(NPM ) run env:validate > /dev/null 2>&1 || echo " $( YELLOW) ⚠ Environment validation failed. Run 'make env-setup' to fix.$( RESET) "
42
+
43
+ # First-time setup for new developers
44
+ setup-first :
45
+ @echo " $( BLUE) Running first-time setup...$( RESET) "
46
+ @$(NPM ) run setup
47
+
48
+ node_modules : package.json
49
+ @echo " $( BLUE) Installing dependencies...$( RESET) "
50
+ @$(NPM ) install
51
+ @echo " $( GREEN) ✓ Dependencies installed$( RESET) "
52
+
53
+ # Install ImageMagick if needed
54
+ deps :
55
+ @echo " $( BLUE) Checking system dependencies...$( RESET) "
56
+ @if ! command -v node > /dev/null; then \
57
+ echo " $( RED) ✗ Node.js is not installed!$( RESET) " ; \
58
+ echo " $( YELLOW) Please install Node.js from https://nodejs.org/$( RESET) " ; \
59
+ exit 1; \
60
+ else \
61
+ echo " $( GREEN) ✓ Node.js is installed$( RESET) " ; \
62
+ fi
63
+ @if ! command -v npm > /dev/null; then \
64
+ echo " $( RED) ✗ npm is not installed!$( RESET) " ; \
65
+ echo " $( YELLOW) Please install npm (it usually comes with Node.js)$( RESET) " ; \
66
+ exit 1; \
67
+ else \
68
+ echo " $( GREEN) ✓ npm is installed$( RESET) " ; \
69
+ fi
70
+ ifeq ($(DETECTED_OS ) ,Darwin)
71
+ @echo "$(BLUE)Checking ImageMagick on macOS...$(RESET)"
72
+ @if ! command -v magick > /dev/null && ! command -v convert > /dev/null; then \
73
+ echo "$(YELLOW)Installing ImageMagick via Homebrew...$(RESET)"; \
74
+ brew install imagemagick || echo "$(RED)Failed to install ImageMagick. Please install manually.$(RESET)"; \
75
+ else \
76
+ echo "$(GREEN)✓ ImageMagick is already installed$(RESET)"; \
77
+ fi
78
+ else ifeq ($(DETECTED_OS),Linux)
79
+ @echo "$(BLUE)Checking ImageMagick on Linux...$(RESET)"
80
+ @if ! command -v magick > /dev/null && ! command -v convert > /dev/null; then \
81
+ echo "$(YELLOW)Installing ImageMagick...$(RESET)"; \
82
+ if command -v apt-get > /dev/null; then \
83
+ sudo apt-get update && sudo apt-get install -y imagemagick || echo "$(RED)Failed to install ImageMagick. Please install manually.$(RESET)"; \
84
+ elif command -v yum > /dev/null; then \
85
+ sudo yum install -y ImageMagick || echo "$(RED)Failed to install ImageMagick. Please install manually.$(RESET)"; \
86
+ else \
87
+ echo "$(RED)Please install ImageMagick manually$(RESET)"; \
88
+ fi \
89
+ else \
90
+ echo "$(GREEN)✓ ImageMagick is already installed$(RESET)"; \
91
+ fi
92
+ else
93
+ @echo "$(YELLOW)Please install ImageMagick manually:$(RESET)"
94
+ @echo "Download from: https://imagemagick.org/script/download.php"
95
+ endif
96
+ @echo "$(GREEN)✓ System dependency checks completed$(RESET)"
97
+
98
+ # Environment setup
99
+ env-setup :
100
+ @echo " $( BLUE) Setting up environment variables...$( RESET) "
101
+ @$(NPM ) run env:setup
102
+
103
+ env-create :
104
+ @echo " $( BLUE) Creating .env file from template...$( RESET) "
105
+ @$(NPM ) run env:create
106
+
107
+ env-check :
108
+ @echo " $( BLUE) Validating environment variables...$( RESET) "
109
+ @$(NPM ) run env:validate
110
+
111
+ # Development commands
112
+ dev :
113
+ @echo " $( BLUE) Starting development server...$( RESET) "
114
+ @$(NPM ) run webpack-watch
115
+
116
+ # Build commands
117
+ build :
118
+ @echo " $( BLUE) Building extension...$( RESET) "
119
+ @$(NPM ) run webpack-prod
120
+ @echo " $( GREEN) ✓ Build completed$( RESET) "
121
+
122
+ test :
123
+ @echo " $( BLUE) Running tests...$( RESET) "
124
+ @$(NPM ) test
125
+
126
+ lint :
127
+ @echo " $( BLUE) Linting code...$( RESET) "
128
+ @$(NPM ) run lint
129
+
130
+ # Package and publish
131
+ package :
132
+ @echo " $( BLUE) Packaging extension...$( RESET) "
133
+ @$(NPM ) run package
134
+ @echo " $( GREEN) ✓ Package created$( RESET) "
135
+
136
+ publish : env-check
137
+ @echo " $( BLUE) Publishing extension...$( RESET) "
138
+ @$(NPM ) run publish
139
+
140
+ # Release commands
141
+ release-patch :
142
+ @echo " $( BLUE) Creating patch release...$( RESET) "
143
+ @$(NPM ) run release:patch
144
+
145
+ release-minor :
146
+ @echo " $( BLUE) Creating minor release...$( RESET) "
147
+ @$(NPM ) run release:minor
148
+
149
+ release-major :
150
+ @echo " $( BLUE) Creating major release...$( RESET) "
151
+ @$(NPM ) run release:major
152
+
153
+ # Clean commands
154
+ clean :
155
+ @echo " $( BLUE) Cleaning build artifacts...$( RESET) "
156
+ @$(NPM ) run clean
157
+ @echo " $( GREEN) ✓ Clean completed$( RESET) "
158
+
159
+ clean-all : clean
160
+ @echo " $( BLUE) Removing node_modules...$( RESET) "
161
+ @rm -rf node_modules
162
+ @echo " $( GREEN) ✓ All cleaned$( RESET) "
163
+
164
+ # Help
165
+ help :
166
+ @echo " $( YELLOW) Markdown Arweave Uploader$( RESET) build commands:"
167
+ @echo " "
168
+ @echo " $( BLUE) Setup:$( RESET) "
169
+ @echo " $( GREEN) make setup-first$( RESET) - Run first-time setup (recommended for new developers)"
170
+ @echo " $( GREEN) make setup$( RESET) - Install dependencies"
171
+ @echo " $( GREEN) make deps$( RESET) - Install system dependencies (ImageMagick)"
172
+ @echo " $( GREEN) make env-setup$( RESET) - Interactive .env setup"
173
+ @echo " $( GREEN) make env-create$( RESET) - Create .env from template"
174
+ @echo " $( GREEN) make env-check$( RESET) - Validate environment variables"
175
+ @echo " "
176
+ @echo " $( BLUE) Development:$( RESET) "
177
+ @echo " $( GREEN) make dev$( RESET) - Start development server with watch mode"
178
+ @echo " $( GREEN) make build$( RESET) - Build the extension"
179
+ @echo " $( GREEN) make test$( RESET) - Run tests"
180
+ @echo " $( GREEN) make lint$( RESET) - Run linter"
181
+ @echo " "
182
+ @echo " $( BLUE) Release:$( RESET) "
183
+ @echo " $( GREEN) make package$( RESET) - Create VSIX package"
184
+ @echo " $( GREEN) make publish$( RESET) - Publish to VS Code Marketplace"
185
+ @echo " $( GREEN) make release-patch$( RESET) - Create patch release (0.0.X)"
186
+ @echo " $( GREEN) make release-minor$( RESET) - Create minor release (0.X.0)"
187
+ @echo " $( GREEN) make release-major$( RESET) - Create major release (X.0.0)"
188
+ @echo " "
189
+ @echo " $( BLUE) Clean:$( RESET) "
190
+ @echo " $( GREEN) make clean$( RESET) - Clean build artifacts"
191
+ @echo " $( GREEN) make clean-all$( RESET) - Clean everything including node_modules"
192
+ @echo " "
193
+
194
+ # Default target
195
+ .DEFAULT_GOAL := help
0 commit comments