GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — BrzzUtils/justfile at main · brzzdev/BrzzUtils

Expand file tree

/

justfile

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
216 lines (192 loc) · 9.99 KB
/

justfile

Copy path

File metadata and controls

216 lines (192 loc) · 9.99 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
set default-list
# Xcode's default DerivedData path is hashed, so its object files have no stable location.
release_derived_data := ".build/release"
release_products := justfile_directory() / release_derived_data / "Build/Products/Release"
scheme := "BrzzUtils-Package"
# Repo-scoped rather than the bare /tmp/swiftformat-base every repo in the family
# shares: two checkouts on different config revisions otherwise fight over one
# file, and each overwrites the other's config mid-commit.
swiftformat_base := "/tmp/swiftformat-base-BrzzUtils"
swiftformat_url := "https://raw.githubusercontent.com/brzzdev/Configs/main/Swift/swiftformat"
# Build the package
build: (build-for "platform=macOS")
[private]
build-for destination *args:
set -o pipefail && xcodebuild build \
-scheme {{ scheme }} \
-destination {{ quote(destination) }} \
{{ args }} \
| xcbeautify
# Build the package for a generic iOS device, no simulator needed
build-ios: (build-for "generic/platform=iOS")
# Build the package in Release for macOS, printing where its object files land
build-release: (build-for "platform=macOS" "-configuration" "Release" "-derivedDataPath" release_derived_data)
@echo {{ quote(release_products) }}
# Fetched rather than vendored, but at most once a day: this is a dependency of
# `format-staged`, which the pre-commit hook runs on every commit, so an
# unconditional fetch would put GitHub on the commit path.
#
# `-f` is load-bearing. Without it curl exits 0 on a 404 and writes the error body
# into the config file, and swiftformat then reformats the whole tree against
# `404: Not Found` from inside the pre-commit hook — silently, since the hook
# stays green. Verified.
[private]
fetch-swiftformat-config:
#!/usr/bin/env bash
set -euo pipefail
# Fresh enough: nothing to do. `find -mmin` is a single stat on one file.
if [ -n "$(find {{ swiftformat_base }} -mmin -1440 2>/dev/null)" ]; then
exit 0
fi
# Per-invocation, because the cache path is shared by every clone and worktree
# of this repo. Given a single hardcoded temp name instead, two concurrent hooks
# write the same file, the first `mv` hands the half-written result over as the
# live config, and the second `mv` then fails on a name that is already gone.
# The trap covers every exit below, so no temp file outlives the recipe.
#
# `mv` carries the temp file's mode across, so the cache lands 0600 rather than
# the 0644 `curl -o` gave it under the default umask. That is the right way
# round for a per-user cache sitting in a world-writable directory.
tmp="$(mktemp {{ swiftformat_base }}.XXXXXX)"
trap 'rm -f "$tmp"' EXIT
if curl -sfL --retry 2 --max-time 10 {{ swiftformat_url }} -o "$tmp"; then
# Same filesystem, so this is an atomic rename: a concurrent reader sees the
# old config or the new one, never a partial write.
mv "$tmp" {{ swiftformat_base }}
exit 0
fi
# Offline, or the config moved. A stale copy still formats correctly enough to
# commit against; no copy at all cannot, so that is the one hard failure.
if [ ! -f {{ swiftformat_base }} ]; then
echo "cannot reach {{ swiftformat_url }} and no cached config at {{ swiftformat_base }}." >&2
exit 1
fi
# The mtime records the last *attempt*, not when the contents arrived. Without
# this a failed refresh leaves the stale copy stale, so every commit from here
# on reaches the curl above and an offline one pays the timeout each time —
# exactly what the daily cache exists to prevent. Nothing reads this mtime but
# the staleness test at the top.
touch {{ swiftformat_base }}
# Format Swift sources
format: fetch-swiftformat-config
swiftformat . --base-config {{ swiftformat_base }}
[private]
format-staged: fetch-swiftformat-config
git-format-staged \
--formatter "swiftformat stdin --stdinpath '{}' --base-config {{ swiftformat_base }}" \
"*.swift"
# Fail on a SwiftLint violation, or on the shared config going missing
lint:
# `--config` is load-bearing, not decoration. With the config merely
# discovered, SwiftLint treats a failed `parent_config` fetch as a warning,
# falls back to its own built-in defaults and exits 0 — a gate that lints
# nothing we asked for. Naming the file explicitly takes SwiftLint's
# "explicitly specified ... -> fail" path instead. Verified on 0.65.1:
# identical rule set (260 rows of `swiftlint rules`), exit 134 when the
# config cannot load, and still exit 0 when it falls back to a cached copy
# of our own config.
#
# Pass this one file, not the parent and child separately: two `--config`
# arguments silently resolve to a *different* rule set — measured, 172 rows
# of that table flip. The local overrides are inlined into `.swiftlint.yml`
# for the same reason a second file is a liability: a referenced local
# config that goes missing is ignored with a warning and a zero exit.
swiftlint --strict --config .swiftlint.yml
# Show outdated Swift packages
outdated:
swift-outdated
# Place pre-commit hook locally
pre-commit:
cp .scripts/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
# Fail when BrzzUtils' required-reason API categories differ from its privacy manifest's
privacy-audit: build-release
#!/usr/bin/env bash
set -euo pipefail
# Apple's required-reason APIs as `nm -u` names them, copied from
# https://developer.apple.com/documentation/bundleresources/describing-use-of-required-reason-api.
# Swift's wrappers reference these same symbols, so none needs its mangled name.
# getattrlist, fgetattrlist, and getattrlistat read timestamps and disk space alike, so
# they count towards both.
required_reason_symbols='
NSPrivacyAccessedAPICategoryActiveKeyboards _objc_msgSend$activeInputModes
NSPrivacyAccessedAPICategoryDiskSpace _NSFileSystemFreeSize
NSPrivacyAccessedAPICategoryDiskSpace _NSFileSystemSize
NSPrivacyAccessedAPICategoryDiskSpace _NSURLVolumeAvailableCapacityForImportantUsageKey
NSPrivacyAccessedAPICategoryDiskSpace _NSURLVolumeAvailableCapacityForOpportunisticUsageKey
NSPrivacyAccessedAPICategoryDiskSpace _NSURLVolumeAvailableCapacityKey
NSPrivacyAccessedAPICategoryDiskSpace _NSURLVolumeTotalCapacityKey
NSPrivacyAccessedAPICategoryDiskSpace _fgetattrlist
NSPrivacyAccessedAPICategoryDiskSpace _fstatfs
NSPrivacyAccessedAPICategoryDiskSpace _fstatvfs
NSPrivacyAccessedAPICategoryDiskSpace _getattrlist
NSPrivacyAccessedAPICategoryDiskSpace _getattrlistat
NSPrivacyAccessedAPICategoryDiskSpace _statfs
NSPrivacyAccessedAPICategoryDiskSpace _statvfs
NSPrivacyAccessedAPICategoryFileTimestamp _NSFileCreationDate
NSPrivacyAccessedAPICategoryFileTimestamp _NSFileModificationDate
NSPrivacyAccessedAPICategoryFileTimestamp _NSURLContentModificationDateKey
NSPrivacyAccessedAPICategoryFileTimestamp _NSURLCreationDateKey
NSPrivacyAccessedAPICategoryFileTimestamp _fgetattrlist
NSPrivacyAccessedAPICategoryFileTimestamp _fstat
NSPrivacyAccessedAPICategoryFileTimestamp _fstatat
NSPrivacyAccessedAPICategoryFileTimestamp _getattrlist
NSPrivacyAccessedAPICategoryFileTimestamp _getattrlistat
NSPrivacyAccessedAPICategoryFileTimestamp _getattrlistbulk
NSPrivacyAccessedAPICategoryFileTimestamp _lstat
NSPrivacyAccessedAPICategoryFileTimestamp _objc_msgSend$fileModificationDate
NSPrivacyAccessedAPICategoryFileTimestamp _stat
NSPrivacyAccessedAPICategorySystemBootTime _mach_absolute_time
NSPrivacyAccessedAPICategorySystemBootTime _objc_msgSend$systemUptime
NSPrivacyAccessedAPICategoryUserDefaults _OBJC_CLASS_$_NSUserDefaults
'
# awk reads the `nm -u` symbols first, then keeps each table row whose symbol is among them.
referenced_rows="$(
nm -u {{ quote(release_products / "BrzzUtils.o") }} \
| awk 'NR == FNR { undefined[$1]; next } $2 in undefined' - <(printf '%s\n' "$required_reason_symbols")
)"
referenced_categories="$(awk '{ print $1 }' <<<"$referenced_rows" | sort -u)"
category_pattern='^NSPrivacyAccessedAPICategory[A-Za-z]+$'
manifest=Sources/BrzzUtils/PrivacyInfo.xcprivacy
count="$(plutil -extract NSPrivacyAccessedAPITypes raw -expect array -o - "$manifest")"
# `set -e` doesn't reach inside the substitution, so a failed entry exits it explicitly.
declared_categories="$(
for ((i = 0; i < count; i++)); do
key_path="NSPrivacyAccessedAPITypes.$i.NSPrivacyAccessedAPIType"
# The trailing x stops `$(…)` stripping newlines that belong to the value itself.
category="$(plutil -extract "$key_path" raw -expect string -o - "$manifest" && echo x)" || exit
category="${category%$'\n'x}"
if [[ ! $category =~ $category_pattern ]]; then
echo "malformed: $key_path is '$category'" >&2
exit 1
fi
echo "$category"
done | sort -u
)"
undeclared="$(comm -23 <(printf '%s\n' "$referenced_categories") <(printf '%s\n' "$declared_categories"))"
stale="$(comm -13 <(printf '%s\n' "$referenced_categories") <(printf '%s\n' "$declared_categories"))"
for category in $undeclared; do
symbols="$(awk -v category="$category" '$1 == category { print $2 }' <<<"$referenced_rows" | paste -sd ' ' -)"
echo "undeclared: $category, referenced by $symbols" >&2
done
for category in $stale; do
echo "stale: $category is declared but never referenced" >&2
done
[ -z "$undeclared$stale" ]
# Run tests
test:
set -o pipefail && xcodebuild test \
-scheme {{ scheme }} \
-destination "platform=macOS" \
| xcbeautify
# Run tests on the pinned iOS simulator; extra arguments go to xcodebuild
test-ios *args:
set -o pipefail && xcodebuild test \
-scheme {{ scheme }} \
-destination "platform=iOS Simulator,name=iPhone 18 Pro,OS=27.0" \
{{ args }} \
| xcbeautify
# Install developer tools
tools:
mise install
just pre-commit
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.