1+ # Celo Composer CLI - Makefile
2+ # Build and deployment automation for @celo/celo-composer
3+
4+ .PHONY : help install clean build test lint format check-git prepare-release publish dry-run dev
5+
6+ # Default target
7+ .DEFAULT_GOAL := help
8+
9+ # Colors for output
10+ BLUE = \033[34m
11+ GREEN = \033[32m
12+ YELLOW = \033[33m
13+ RED = \033[31m
14+ NC = \033[0m # No Color
15+
16+ # Variables
17+ PACKAGE_NAME = @celo/celo-composer
18+ NODE_VERSION = $(shell node --version)
19+ NPM_VERSION = $(shell npm --version)
20+
21+ help : # # Show this help message
22+ @echo " $( BLUE) Celo Composer CLI - Build & Deployment$( NC) "
23+ @echo " $( BLUE) =====================================$( NC) "
24+ @echo " Node.js: $( NODE_VERSION) "
25+ @echo " npm: $( NPM_VERSION) "
26+ @echo " "
27+ @echo " $( GREEN) Available commands:$( NC) "
28+ @awk ' BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " $(BLUE)%-15s$(NC) %s\n", $$1, $$2}' $(MAKEFILE_LIST )
29+
30+ install : # # Install dependencies
31+ @echo " $( YELLOW) Installing dependencies...$( NC) "
32+ npm install
33+
34+ clean : # # Clean build artifacts and dependencies
35+ @echo " $( YELLOW) Cleaning build artifacts...$( NC) "
36+ npm run build
37+ rm -rf dist/
38+ rm -rf node_modules/
39+ rm -f oclif.manifest.json
40+ rm -f tsconfig.tsbuildinfo
41+
42+ build : # # Build the project
43+ @echo " $( YELLOW) Building project...$( NC) "
44+ npm run build
45+ @echo " $( GREEN) ✓ Build completed$( NC) "
46+
47+ test : # # Run tests
48+ @echo " $( YELLOW) Running tests...$( NC) "
49+ npm test
50+ @echo " $( GREEN) ✓ Tests passed$( NC) "
51+
52+ lint : # # Run linter
53+ @echo " $( YELLOW) Running linter...$( NC) "
54+ npm run lint
55+ @echo " $( GREEN) ✓ Linting completed$( NC) "
56+
57+ format : # # Format code (if prettier is available)
58+ @echo " $( YELLOW) Formatting code...$( NC) "
59+ @if command -v prettier > /dev/null 2>&1 ; then \
60+ npx prettier --write " src/**/*.ts" " test/**/*.ts" ; \
61+ echo " $( GREEN) ✓ Code formatted$( NC) " ; \
62+ else \
63+ echo " $( YELLOW) Prettier not found, skipping formatting$( NC) " ; \
64+ fi
65+
66+ dev : # # Start development mode with file watching
67+ @echo " $( YELLOW) Starting development mode...$( NC) "
68+ @echo " $( BLUE) Use './bin/run.js create --help' to test CLI commands$( NC) "
69+ npm run build
70+ @echo " $( GREEN) ✓ Development build ready$( NC) "
71+
72+ check-git : # # Check if git is clean and on main branch
73+ @echo " $( YELLOW) Checking git status...$( NC) "
74+ @if [ -n " $$ (git status --porcelain)" ]; then \
75+ echo " $( RED) ✗ Git working directory is not clean$( NC) " ; \
76+ git status --short; \
77+ exit 1; \
78+ fi
79+ @echo " $( GREEN) ✓ Git working directory is clean$( NC) "
80+
81+ check-tests : build test lint # # Run all checks (build, test, lint)
82+ @echo " $( GREEN) ✓ All checks passed$( NC) "
83+
84+ prepare-release : check-git check-tests # # Prepare for release (run all checks)
85+ @echo " $( YELLOW) Preparing release...$( NC) "
86+ npm run prepack
87+ @echo " $( GREEN) ✓ Release prepared$( NC) "
88+
89+ version-patch : prepare-release # # Bump patch version (1.0.0 -> 1.0.1)
90+ @echo " $( YELLOW) Bumping patch version...$( NC) "
91+ npm version patch
92+ @echo " $( GREEN) ✓ Patch version bumped$( NC) "
93+
94+ version-minor : prepare-release # # Bump minor version (1.0.0 -> 1.1.0)
95+ @echo " $( YELLOW) Bumping minor version...$( NC) "
96+ npm version minor
97+ @echo " $( GREEN) ✓ Minor version bumped$( NC) "
98+
99+ version-major : prepare-release # # Bump major version (1.0.0 -> 2.0.0)
100+ @echo " $( YELLOW) Bumping major version...$( NC) "
101+ npm version major
102+ @echo " $( GREEN) ✓ Major version bumped$( NC) "
103+
104+ dry-run : prepare-release # # Perform a dry run of npm publish
105+ @echo " $( YELLOW) Performing dry run...$( NC) "
106+ npm publish --dry-run
107+ @echo " $( GREEN) ✓ Dry run completed$( NC) "
108+
109+ publish : prepare-release # # Publish to npm (requires npm authentication)
110+ @echo " $( YELLOW) Publishing to npm...$( NC) "
111+ @echo " $( RED) WARNING: This will publish $( PACKAGE_NAME) to npm!$( NC) "
112+ @read -p " Are you sure? (y/N): " confirm && [ " $$ confirm" = " y" ] || exit 1
113+ npm publish
114+ @echo " $( GREEN) ✓ Published successfully!$( NC) "
115+
116+ publish-beta : prepare-release # # Publish beta version to npm
117+ @echo " $( YELLOW) Publishing beta version to npm...$( NC) "
118+ npm publish --tag beta
119+ @echo " $( GREEN) ✓ Beta version published!$( NC) "
120+
121+ quick-test : # # Quick test of CLI functionality
122+ @echo " $( YELLOW) Testing CLI functionality...$( NC) "
123+ npm run build
124+ ./bin/run.js create --help
125+ @echo " $( GREEN) ✓ CLI is working$( NC) "
126+
127+ release-patch : version-patch publish # # Full patch release workflow
128+ @echo " $( GREEN) ✓ Patch release completed!$( NC) "
129+
130+ release-minor : version-minor publish # # Full minor release workflow
131+ @echo " $( GREEN) ✓ Minor release completed!$( NC) "
132+
133+ release-major : version-major publish # # Full major release workflow
134+ @echo " $( GREEN) ✓ Major release completed!$( NC) "
135+
136+ status : # # Show current package status
137+ @echo " $( BLUE) Package Status$( NC) "
138+ @echo " $( BLUE) ==============$( NC) "
139+ @echo " Name: $( PACKAGE_NAME) "
140+ @echo " Version: $$ (npm list --depth=0 | head -1 | sed 's/.*@//')"
141+ @echo " Main: $$ (node -p " require(' ./package.json' ).main" )"
142+ @echo " Bin: $$ (node -p " require(' ./package.json' ).bin[' celo-composer' ]" )"
143+ @echo " "
144+ @echo " $( BLUE) Files that will be published:$( NC) "
145+ @npm pack --dry-run 2> /dev/null | tail -n +2
146+
147+ info : # # Show npm package info
148+ @echo " $( YELLOW) Fetching npm package info...$( NC) "
149+ npm info $(PACKAGE_NAME )
150+
151+ # Development helpers
152+ watch : # # Watch for changes and rebuild
153+ @echo " $( YELLOW) Watching for changes...$( NC) "
154+ @echo " $( BLUE) Press Ctrl+C to stop$( NC) "
155+ @while true ; do \
156+ inotifywait -qq -r -e modify,create,delete src/ 2> /dev/null || \
157+ (echo " $( YELLOW) inotifywait not available, using basic loop$( NC) " && sleep 2); \
158+ make build; \
159+ echo " $( GREEN) ✓ Rebuilt at $$ (date)$( NC) " ; \
160+ done
161+
162+ install-dev : # # Install development dependencies globally
163+ @echo " $( YELLOW) Installing development tools...$( NC) "
164+ npm install -g prettier typescript ts-node
165+ @echo " $( GREEN) ✓ Development tools installed$( NC) "
166+
167+ # Cleanup commands
168+ clean-all : clean # # Clean everything including node_modules
169+ @echo " $( GREEN) ✓ Everything cleaned$( NC) "
170+
171+ reset : clean-all install build # # Reset project (clean + install + build)
172+ @echo " $( GREEN) ✓ Project reset completed$( NC) "
0 commit comments