Skip to content

Commit 4f6d1b0

Browse files
authored
Merge pull request #7 from easydev991/develop-1.4
Добавил Makefile для автоматизации настройки зависимостей. - Подсказку можно получить по команде make help - Установить все можно по команде make install Дополнительно сгенерировал скриншоты и отформатировал код (настроил swiftformat), обновил зависимости (гемы).
2 parents 4b6fb0f + 5472966 commit 4f6d1b0

40 files changed

+301
-152
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ SwiftUI-Days.xcodeproj/xcuserdata/oleg991.xcuserdatad/xcdebugger/Breakpoints_v2.
33
fastlane/screenshots/screenshots.html
44
fastlane/report.xml
55
SwiftUI-Days.xcodeproj/project.xcworkspace/xcuserdata/oleg991.xcuserdatad/UserInterfaceState.xcuserstate
6+
.DS_Store

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.2.2

.swift-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.0

.swiftformat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--exclude SwiftUI-DaysUITests/SnapshotHelper.swift

Gemfile.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@ GEM
1010
artifactory (3.0.17)
1111
atomos (0.1.3)
1212
aws-eventstream (1.3.2)
13-
aws-partitions (1.1079.0)
14-
aws-sdk-core (3.222.1)
13+
aws-partitions (1.1109.0)
14+
aws-sdk-core (3.224.1)
1515
aws-eventstream (~> 1, >= 1.3.0)
1616
aws-partitions (~> 1, >= 1.992.0)
1717
aws-sigv4 (~> 1.9)
1818
base64
1919
jmespath (~> 1, >= 1.6.1)
2020
logger
21-
aws-sdk-kms (1.99.0)
21+
aws-sdk-kms (1.101.0)
2222
aws-sdk-core (~> 3, >= 3.216.0)
2323
aws-sigv4 (~> 1.5)
24-
aws-sdk-s3 (1.183.0)
25-
aws-sdk-core (~> 3, >= 3.216.0)
24+
aws-sdk-s3 (1.188.0)
25+
aws-sdk-core (~> 3, >= 3.224.1)
2626
aws-sdk-kms (~> 1)
2727
aws-sigv4 (~> 1.5)
2828
aws-sigv4 (1.11.0)
2929
aws-eventstream (~> 1, >= 1.0.2)
3030
babosa (1.0.4)
31-
base64 (0.2.0)
31+
base64 (0.3.0)
3232
claide (1.1.0)
3333
colored (1.2)
3434
colored2 (3.1.2)
@@ -70,7 +70,7 @@ GEM
7070
faraday_middleware (1.2.1)
7171
faraday (~> 1.0)
7272
fastimage (2.4.0)
73-
fastlane (2.227.0)
73+
fastlane (2.227.2)
7474
CFPropertyList (>= 2.3, < 4.0.0)
7575
addressable (>= 2.8, < 3.0.0)
7676
artifactory (~> 3.0)
@@ -110,7 +110,7 @@ GEM
110110
tty-spinner (>= 0.8.0, < 1.0.0)
111111
word_wrap (~> 1.0.0)
112112
xcodeproj (>= 1.13.0, < 2.0.0)
113-
xcpretty (~> 0.4.0)
113+
xcpretty (~> 0.4.1)
114114
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
115115
fastlane-sirp (1.0.0)
116116
sysrandom (~> 1.0)
@@ -157,7 +157,7 @@ GEM
157157
httpclient (2.9.0)
158158
mutex_m
159159
jmespath (1.6.2)
160-
json (2.10.2)
160+
json (2.12.2)
161161
jwt (2.10.1)
162162
base64
163163
logger (1.7.0)
@@ -172,8 +172,8 @@ GEM
172172
optparse (0.6.0)
173173
os (1.1.4)
174174
plist (3.7.2)
175-
public_suffix (6.0.1)
176-
rake (13.2.1)
175+
public_suffix (6.0.2)
176+
rake (13.3.0)
177177
representable (3.2.0)
178178
declarative (< 0.1.0)
179179
trailblazer-option (>= 0.1.1, < 0.2.0)
@@ -184,7 +184,7 @@ GEM
184184
ruby2_keywords (0.0.5)
185185
rubyzip (2.4.1)
186186
security (0.1.5)
187-
signet (0.19.0)
187+
signet (0.20.0)
188188
addressable (~> 2.8)
189189
faraday (>= 0.17.5, < 3.a)
190190
jwt (>= 1.5, < 3.0)

Makefile

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
.PHONY: help install format update fastlane
2+
3+
# Цвета ANSI
4+
YELLOW=\033[1;33m
5+
GREEN=\033[1;32m
6+
RED=\033[1;31m
7+
RESET=\033[0m
8+
9+
RUBY_VERSION=3.2.2
10+
11+
help:
12+
@echo ""
13+
@echo "Доступные команды Makefile:"
14+
@echo ""
15+
@echo " make help - Показать это справочное сообщение."
16+
@echo " make install - Проверить и установить все необходимые инструменты и зависимости для проекта:"
17+
@echo " Homebrew, rbenv, Ruby, Bundler, Ruby-гемы (включая fastlane), SwiftFormat."
18+
@echo " make format - Запустить автоматическое форматирование Swift-кода с помощью SwiftFormat."
19+
@echo " make update - Обновить Ruby-зависимости (например, fastlane) до последних версий и обновить Gemfile.lock."
20+
@echo " make fastlane - Запустить fastlane snapshot для генерации скриншотов приложения (использует bundle exec fastlane snapshot)."
21+
@echo ""
22+
@echo "Рекомендуется сначала выполнить 'make install' для установки всех зависимостей."
23+
@echo ""
24+
25+
install:
26+
@printf "$(YELLOW)Проверка наличия Homebrew...$(RESET)\n"
27+
@if ! command -v brew >/dev/null 2>&1; then \
28+
printf "$(YELLOW)Homebrew не установлен.$(RESET)\n"; \
29+
read -p "Установить Homebrew? (да/нет) " answer; \
30+
if echo "$${answer}" | grep -iq "^да$$"; then \
31+
/bin/bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; \
32+
printf "$(GREEN)Homebrew успешно установлен.$(RESET)\n"; \
33+
else \
34+
printf "$(RED)Невозможно продолжить без Homebrew.$(RESET)\n"; \
35+
exit 1; \
36+
fi \
37+
else \
38+
printf "$(GREEN)Homebrew уже установлен.$(RESET)\n"; \
39+
fi
40+
41+
@printf "$(YELLOW)Проверка наличия rbenv...$(RESET)\n"
42+
@if ! command -v rbenv >/dev/null 2>&1; then \
43+
printf "$(YELLOW)rbenv не установлен.$(RESET)\n"; \
44+
read -p "Установить rbenv? (да/нет) " answer; \
45+
if echo "$${answer}" | grep -iq "^да$$"; then \
46+
brew install rbenv ruby-build; \
47+
printf 'eval "$$(rbenv init -)"\n' >> ~/.bash_profile; \
48+
printf "$(GREEN)rbenv успешно установлен.$(RESET)\n"; \
49+
else \
50+
printf "$(RED)Невозможно продолжить без rbenv.$(RESET)\n"; \
51+
exit 1; \
52+
fi \
53+
else \
54+
printf "$(GREEN)rbenv уже установлен.$(RESET)\n"; \
55+
fi
56+
57+
@printf "$(YELLOW)Проверка наличия Ruby версии $(RUBY_VERSION)...$(RESET)\n"
58+
@if ! rbenv versions | grep -q $(RUBY_VERSION); then \
59+
printf "$(YELLOW)Ruby $(RUBY_VERSION) не установлен.$(RESET)\n"; \
60+
read -p "Установить Ruby $(RUBY_VERSION)? (да/нет) " answer; \
61+
if echo "$${answer}" | grep -iq "^да$$"; then \
62+
rbenv install $(RUBY_VERSION); \
63+
printf "$(GREEN)Ruby $(RUBY_VERSION) успешно установлен.$(RESET)\n"; \
64+
else \
65+
printf "$(RED)Невозможно продолжить без Ruby $(RUBY_VERSION).$(RESET)\n"; \
66+
exit 1; \
67+
fi \
68+
else \
69+
printf "$(GREEN)Ruby $(RUBY_VERSION) уже установлен.$(RESET)\n"; \
70+
fi
71+
72+
@printf "$(YELLOW)Проверка файла .ruby-version...$(RESET)\n"
73+
@if [ ! -f .ruby-version ] || [ "$$(cat .ruby-version)" != "$(RUBY_VERSION)" ]; then \
74+
printf "$(YELLOW)Файл .ruby-version не найден или содержит неверную версию.$(RESET)\n"; \
75+
read -p "Создать/обновить файл .ruby-version с версией $(RUBY_VERSION)? (да/нет) " answer; \
76+
if echo "$${answer}" | grep -iq "^да$$"; then \
77+
echo "$(RUBY_VERSION)" > .ruby-version; \
78+
printf "$(GREEN)Файл .ruby-version обновлён.$(RESET)\n"; \
79+
else \
80+
printf "$(YELLOW)Создание файла .ruby-version пропущено.$(RESET)\n"; \
81+
fi \
82+
else \
83+
printf "$(GREEN)Файл .ruby-version уже корректен.$(RESET)\n"; \
84+
fi
85+
86+
@printf "$(YELLOW)Инициализация rbenv и активация Ruby $(RUBY_VERSION) локально...$(RESET)\n"
87+
@export PATH="$$HOME/.rbenv/bin:$$PATH"; \
88+
eval "$$(rbenv init -)"; \
89+
rbenv local $(RUBY_VERSION); \
90+
rbenv shell $(RUBY_VERSION); \
91+
printf "$(GREEN)Ruby $(RUBY_VERSION) активирован локально для проекта.$(RESET)\n"
92+
93+
@printf "$(YELLOW)Проверка наличия Bundler нужной версии...$(RESET)\n"
94+
@if [ -f Gemfile.lock ]; then \
95+
BUNDLER_VERSION=$$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1 | xargs); \
96+
if ! gem list -i bundler -v "$$BUNDLER_VERSION" >/dev/null 2>&1; then \
97+
printf "$(YELLOW)Bundler версии $$BUNDLER_VERSION не установлен.$(RESET)\n"; \
98+
read -p "Установить Bundler $$BUNDLER_VERSION? (да/нет) " answer; \
99+
if echo "$${answer}" | grep -iq "^да$$"; then \
100+
gem install bundler -v "$$BUNDLER_VERSION"; \
101+
printf "$(GREEN)Bundler версии $$BUNDLER_VERSION успешно установлен.$(RESET)\n"; \
102+
else \
103+
printf "$(RED)Невозможно продолжить без Bundler $$BUNDLER_VERSION.$(RESET)\n"; \
104+
exit 1; \
105+
fi \
106+
else \
107+
printf "$(GREEN)Bundler версии $$BUNDLER_VERSION уже установлен.$(RESET)\n"; \
108+
fi \
109+
else \
110+
printf "$(YELLOW)Файл Gemfile.lock не найден, пропуск проверки версии Bundler.$(RESET)\n"; \
111+
fi
112+
113+
@printf "$(YELLOW)Проверка Ruby-зависимостей из Gemfile...$(RESET)\n"
114+
@if [ -f Gemfile ]; then \
115+
if ! bundle check >/dev/null 2>&1; then \
116+
printf "$(YELLOW)Зависимости не установлены. Выполняется bundle install...$(RESET)\n"; \
117+
bundle install; \
118+
if [ $$? -ne 0 ]; then \
119+
printf "$(RED)Невозможно продолжить без всех Ruby-зависимостей.$(RESET)\n"; \
120+
exit 1; \
121+
fi; \
122+
printf "$(GREEN)Все Ruby-зависимости успешно установлены.$(RESET)\n"; \
123+
else \
124+
printf "$(GREEN)Все Ruby-зависимости уже установлены.$(RESET)\n"; \
125+
fi \
126+
else \
127+
printf "$(YELLOW)Файл Gemfile не найден, пропуск установки Ruby-зависимостей.$(RESET)\n"; \
128+
fi
129+
130+
@printf "$(YELLOW)Проверка наличия SwiftFormat...$(RESET)\n"
131+
@if ! command -v swiftformat >/dev/null 2>&1; then \
132+
printf "$(YELLOW)SwiftFormat не установлен.$(RESET)\n"; \
133+
read -p "Установить SwiftFormat? (да/нет) " answer; \
134+
if echo "$${answer}" | grep -iq "^да$$"; then \
135+
brew install swiftformat; \
136+
printf "$(GREEN)SwiftFormat успешно установлен.$(RESET)\n"; \
137+
else \
138+
printf "$(RED)Невозможно продолжить без SwiftFormat.$(RESET)\n"; \
139+
exit 1; \
140+
fi \
141+
else \
142+
printf "$(GREEN)SwiftFormat уже установлен.$(RESET)\n"; \
143+
fi
144+
145+
format:
146+
@if ! command -v brew >/dev/null 2>&1 || ! command -v swiftformat >/dev/null 2>&1; then \
147+
$(MAKE) install; \
148+
fi; \
149+
if ! command -v brew >/dev/null 2>&1 || ! command -v swiftformat >/dev/null 2>&1; then \
150+
printf "$(RED)Невозможно выполнить команду без нужных зависимостей$(RESET)\n"; \
151+
exit 1; \
152+
fi
153+
@printf "$(YELLOW)Запуск SwiftFormat...$(RESET)\n"
154+
@swiftformat .
155+
156+
fastlane:
157+
@if ! command -v fastlane >/dev/null 2>&1; then \
158+
printf "$(YELLOW)fastlane не найден. Выполняется установка зависимостей...$(RESET)\n"; \
159+
$(MAKE) install; \
160+
fi; \
161+
if ! command -v fastlane >/dev/null 2>&1; then \
162+
printf "$(RED)Невозможно выполнить команду без нужных зависимостей$(RESET)\n"; \
163+
exit 1; \
164+
fi
165+
@printf "$(YELLOW)Запуск fastlane snapshot...$(RESET)\n"
166+
@bundle exec fastlane snapshot
167+
168+
update:
169+
@printf "$(YELLOW)Обновление fastlane и других Ruby-зависимостей...$(RESET)\n"
170+
@bundle update
171+
@printf "$(GREEN)Гемы обновлены. Не забудьте закоммитить новый Gemfile.lock!$(RESET)\n"

SwiftUI-Days/Models/AppTheme.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ enum AppTheme: Int, CaseIterable, Identifiable {
1212
case system = 0
1313
case light = 1
1414
case dark = 2
15-
15+
1616
var title: LocalizedStringResource {
1717
switch self {
1818
case .system: "System"
1919
case .light: "Light"
2020
case .dark: "Dark"
2121
}
2222
}
23-
23+
2424
var colorScheme: ColorScheme? {
2525
switch self {
2626
case .light: .light

SwiftUI-Days/Models/BackupFileDocument.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ struct BackupFileDocument: FileDocument {
1414
static func toBackupItem(item: Item) -> BackupItem {
1515
.init(title: item.title, details: item.details, timestamp: item.timestamp)
1616
}
17-
17+
1818
let items: [BackupItem]
19-
19+
2020
init(items: [BackupItem]) {
2121
self.items = items
2222
}
23-
23+
2424
init(configuration: ReadConfiguration) throws {
2525
guard let data = configuration.file.regularFileContents else {
2626
throw CocoaError(.fileReadCorruptFile)
2727
}
2828
items = try JSONDecoder().decode([BackupItem].self, from: data)
2929
}
30-
31-
func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
30+
31+
func fileWrapper(configuration _: WriteConfiguration) throws -> FileWrapper {
3232
let data = try JSONEncoder().encode(items)
3333
return FileWrapper(regularFileWithContents: data)
3434
}
@@ -39,7 +39,7 @@ extension BackupFileDocument {
3939
let title: String
4040
let details: String
4141
let timestamp: Date
42-
42+
4343
var realItem: Item {
4444
.init(title: title, details: details, timestamp: timestamp)
4545
}

SwiftUI-Days/Models/Item.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class Item {
2828
let daysCount = Self.calendar.dateComponents([.day], from: startDate, to: endDate).day
2929
return daysCount ?? 0
3030
}
31-
31+
3232
var backupItem: BackupFileDocument.BackupItem {
3333
.init(title: title, details: details, timestamp: timestamp)
3434
}
@@ -38,8 +38,8 @@ extension Item {
3838
static func predicate(searchText: String) -> Predicate<Item> {
3939
#Predicate { item in
4040
searchText.isEmpty
41-
|| item.title.contains(searchText)
42-
|| item.details.contains(searchText)
41+
|| item.title.contains(searchText)
42+
|| item.details.contains(searchText)
4343
}
4444
}
4545
}

SwiftUI-Days/Models/SortOrder+.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extension SortOrder: @retroactive RawRepresentable {
2525
default: return nil
2626
}
2727
}
28-
28+
2929
public var rawValue: Int {
3030
switch self {
3131
case .forward: 0

0 commit comments

Comments
 (0)