-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
132 lines (110 loc) · 4.55 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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/make
ifneq (,$(wildcard ./.env))
include .env
export $(shell sed 's/=.*//' .env)
endif
SHELL=/bin/bash
.PHONY: all help configure-git configure clean build-docker docker-test docker-lint docker-doc docker-publish docker-down docker-kill lint fix-lint test doc rmdoc publish publish-n fix-packages-version version
.ONESHELL:
DCK_CMP_UP=docker-compose up -d --remove-orphans
all: help
help:
@echo "\tMakefile for notifiable_iterables"
@echo ''
@echo " usage: $0 [COMMAND]"
@echo ''
@echo "The available commands are:"
@echo ''
@echo " help - Print this help text and exit."
@echo " configure - Configure the project folder."
@echo " configure-git - Configure the project folder for git usage. Use 'configure' for global configuration of the project."
@echo " build-docker - Build the Docker image associated to this project. All command starting with 'docker-' needs this docker image to work."
@echo " docker-test - Launch the tests from a container."
@echo " docker-lint - Check the code format from a container."
@echo " docker-doc - Generate the documentation from a container."
@echo " docker-publish - Publish the flutter package from a container."
@echo " docker-down - Call 'docker-compose down' and prune."
@echo " docker-kill - Kill all docker container. Use this command with caution."
@echo " lint - Check the code format."
@echo " fix-lint - Fix the code format."
@echo " test - Launch the tests."
@echo " doc - Generate the documentation."
@echo " rmdoc - Remove the documentation."
@echo " publish - Publish the flutter package."
@echo " publish-n - Publish the flutter package with the '--dry-run' option (for testing)."
.git/hooks/pre-commit:
curl -fsSL "https://gist.githubusercontent.com/Cynnexis/16b64199d9a94684a638f08b3fc893d3/raw/pre-commit" -o ".git/hooks/pre-commit"
@if command -v "dos2unix" > /dev/null 2>&1; then \
dos2unix ".git/hooks/pre-commit"; \
else \
echo "dos2unix not found. If you are on Windows, you may consider installing it."; \
fi
configure-git: .git/hooks/pre-commit
configure: configure-git
flutter pub get
clean:
flutter clean
rm -rf coverage
rm -f .coverage
build-docker:
docker build -t cynnexis/notifiable_iterables .
docker-test:
docker run --rm -it cynnexis/notifiable_iterables test
docker-lint:
docker run --rm -it cynnexis/notifiable_iterables lint
docker-doc:
docker run --rm -it -v "$$(pwd):/build" cynnexis/notifiable_iterables doc
docker-publish:
docker run --rm -it cynnexis/notifiable_iterables publish
docker-down:
docker-compose down --remove-orphans --volumes
docker-kill:
docker rm -f $$(docker ps -aq) || docker rmi -f $$(docker images -f "dangling=true" -q) || docker system prune -f
lint:
./docker-entrypoint.sh lint
fix-lint:
./docker-entrypoint.sh fix-lint
test:
flutter test --coverage test/*_test.dart
doc:
./docker-entrypoint.sh doc
rmdoc:
./docker-entrypoint.sh rmdoc
publish:
./docker-entrypoint.sh publish
publish-n:
./docker-entrypoint.sh publish --dry-run
fix-packages-version:
@set -euo pipefail
# List all type of dependencies
dependency_types=('dependencies' 'dev_dependencies')
for dependency_type in "$${dependency_types[@]}"; do
# List all dependencies from the pubspec.yaml file
dependencies=$$(yq --no-colors --no-doc eval ".\"$$dependency_type\" | keys" pubspec.y[a]ml | awk '{print $$2;}')
while read -r dependency; do
# Treat only dependencies that have "any" as version
if [[ $$(yq --no-colors --no-doc eval ".\"$$dependency_type\".\"$$dependency\"" pubspec.y[a]ml 2> /dev/null) == "any" ]]; then
# Get the version from pubspec.lock
version=$$(yq --no-colors --no-doc eval ".packages.\"$$dependency\".version" pubspec.lock 2> /dev/null)
# If the fetched version is valid, put it in the pubspec.yaml
if [[ -n $$version && $$version != "null" ]]; then
echo "$$dependency: $$version"
sed -i -Ee "s@^(\s\+)$${dependency}:\s*any\$$@\1$${dependency}: $$version@g" pubspec.y[a]ml
else
echo "Warning: no version found for \"$${dependency}\" from the group \"$${dependency_type}\"" 1>&2
fi
fi
done <<< "$$dependencies"
done
version:
@set -e
VERSION="Package version $$(grep 'version:' pubspec.yaml | head -1 | awk '{print $$2}')"
if command -v "git" > /dev/null 2>&1; then
if [[ "$(git rev-parse --abbrev-ref HEAD)" == "master" ]]; then
echo "$$VERSION"
else \
echo "$$VERSION - rev $$(git rev-parse HEAD)"
fi
else
echo "$$VERSION - rev $$(cat ".git/$$(grep "ref:" .git/HEAD | head -1 | awk '{print $$2}')")"
fi