-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
74 lines (58 loc) · 1.96 KB
/
Makefile
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
# Define the name of your gem
GEM_NAME = crimson-falcon
# Define the version of your gem
GEM_VERSION := $(shell ruby -r './lib/crimson-falcon/version.rb' -e 'puts Falcon::VERSION')
# Define the path to your gemspec file
GEMSPEC_PATH = $(GEM_NAME).gemspec
# Define shell commands
BUILD_COMMAND = gem build $(GEMSPEC_PATH)
INSTALL_COMMAND = gem install $(GEM_NAME)-$(GEM_VERSION).gem
UNINSTALL_COMMAND = gem uninstall $(GEM_NAME)
CLEAN_COMMAND = rm -f $(GEM_NAME)-$(GEM_VERSION).gem
# Directory where the ruby files are located (regex fix)
DIR := lib/crimson-falcon/
#------------------------
# Development tasks
#------------------------
.PHONY: default build install uninstall rebuild
default: build
build:
@echo "Building gem..."
@$(BUILD_COMMAND)
install:
@echo "Installing gem..."
@$(INSTALL_COMMAND)
uninstall:
@echo "Uninstalling gem..."
@$(UNINSTALL_COMMAND)
clean:
@echo "Cleaning up..."
@$(CLEAN_COMMAND)
rebuild: uninstall build install clean
#------------------------
# SDK Generation tasks
#------------------------
.PHONY: build-sdk fix-regex clean-generated-files rubocop
build-sdk:
@echo "Generating SDK..."
@openapi-generator generate -i .openapi-generator/swagger.json -g ruby -c .openapi-generator/config.yml -t .openapi-generator/templates
fix-regex:
@echo "Fixing regex..."
ifeq ($(shell uname -s),Darwin) # If the operating system is macOS
@find $(DIR) -name "*.rb" -print0 | while IFS= read -r -d '' file; do \
sed -i '' -E 's/\[0-9a-z-_]/[0-9a-z\\-_]/g' "$$file" ; \
done
else # If the operating system is Linux
@find $(DIR) -name "*.rb" -print0 | while IFS= read -r -d '' file; do \
sed -i 's/\[0-9a-z-_]/[0-9a-z\\-_]/g' "$$file" ; \
done
endif
rubocop:
@echo "Running rubocop..."
@rubocop -a
clean-generated-files:
@echo "Cleaning up generated files..."
@rm -rf docs/* lib/crimson-falcon/models/* lib/crimson-falcon/api/* spec/*
.PHONY: generate
generate: clean-generated-files build-sdk fix-regex rubocop
@echo "SDK generated successfully."