Skip to content

Commit f10602c

Browse files
committed
installers fixations
1 parent 68cc672 commit f10602c

4 files changed

Lines changed: 137 additions & 6 deletions

File tree

docs/website/web_assets/installers/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ delegate to the maintained lifecycle scripts under `install/`:
1111
- `install/macos.sh`
1212
- `install/windows.ps1`
1313

14+
To reduce bloat, website installers use sparse checkout and download only
15+
required runtime paths for the selected mode. `README.md` and `LICENSE` are
16+
included with the installed framework bundle.
17+
1418
## Files
1519

1620
- `asrfacet-rb-installer-linux.sh`

docs/website/web_assets/installers/asrfacet-rb-installer-linux.sh

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,29 @@ Options:
4646
EOF
4747
}
4848

49+
required_paths_for_mode() {
50+
local paths=("install/linux.sh")
51+
case "$MODE" in
52+
install|update|test)
53+
paths+=(
54+
"bin"
55+
"config"
56+
"lib"
57+
"man"
58+
"wordlists"
59+
"Gemfile"
60+
"Gemfile.lock"
61+
"asrfacet-rb.gemspec"
62+
"README.md"
63+
"LICENSE"
64+
)
65+
[ "$MODE" = "test" ] && paths+=("spec")
66+
;;
67+
esac
68+
69+
printf '%s\n' "${paths[@]}"
70+
}
71+
4972
select_mode() {
5073
if [ "$NO_PROMPT" = "yes" ]; then
5174
MODE="install"
@@ -111,8 +134,22 @@ prepare_workspace() {
111134

112135
download_repo() {
113136
local repo_dir="$WORK_DIR/source"
114-
info "Downloading ASRFacet-Rb from GitHub."
115-
run_cmd git clone --depth 1 --branch "$BRANCH" "$REPO_URL" "$repo_dir"
137+
info "Downloading only required ASRFacet-Rb files from GitHub."
138+
139+
if git clone --depth 1 --filter=blob:none --sparse --branch "$BRANCH" "$REPO_URL" "$repo_dir"; then
140+
local sparse_paths=()
141+
mapfile -t sparse_paths < <(required_paths_for_mode)
142+
(
143+
cd "$repo_dir" || exit 1
144+
git sparse-checkout init --no-cone &&
145+
git sparse-checkout set --no-cone "${sparse_paths[@]}"
146+
) || fail "Unable to apply sparse checkout for required files."
147+
else
148+
warn "Sparse checkout is unavailable in this git environment. Falling back to full shallow clone."
149+
run_cmd rm -rf "$repo_dir"
150+
run_cmd git clone --depth 1 --branch "$BRANCH" "$REPO_URL" "$repo_dir"
151+
fi
152+
116153
printf '%s\n' "$repo_dir"
117154
}
118155

docs/website/web_assets/installers/asrfacet-rb-installer-macos.sh

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,29 @@ Options:
4646
EOF
4747
}
4848

49+
required_paths_for_mode() {
50+
local paths=("install/macos.sh")
51+
case "$MODE" in
52+
install|update|test)
53+
paths+=(
54+
"bin"
55+
"config"
56+
"lib"
57+
"man"
58+
"wordlists"
59+
"Gemfile"
60+
"Gemfile.lock"
61+
"asrfacet-rb.gemspec"
62+
"README.md"
63+
"LICENSE"
64+
)
65+
[ "$MODE" = "test" ] && paths+=("spec")
66+
;;
67+
esac
68+
69+
printf '%s\n' "${paths[@]}"
70+
}
71+
4972
select_mode() {
5073
if [ "$NO_PROMPT" = "yes" ]; then
5174
MODE="install"
@@ -111,8 +134,22 @@ prepare_workspace() {
111134

112135
download_repo() {
113136
local repo_dir="$WORK_DIR/source"
114-
info "Downloading ASRFacet-Rb from GitHub."
115-
run_cmd git clone --depth 1 --branch "$BRANCH" "$REPO_URL" "$repo_dir"
137+
info "Downloading only required ASRFacet-Rb files from GitHub."
138+
139+
if git clone --depth 1 --filter=blob:none --sparse --branch "$BRANCH" "$REPO_URL" "$repo_dir"; then
140+
local sparse_paths=()
141+
mapfile -t sparse_paths < <(required_paths_for_mode)
142+
(
143+
cd "$repo_dir" || exit 1
144+
git sparse-checkout init --no-cone &&
145+
git sparse-checkout set --no-cone "${sparse_paths[@]}"
146+
) || fail "Unable to apply sparse checkout for required files."
147+
else
148+
warn "Sparse checkout is unavailable in this git environment. Falling back to full shallow clone."
149+
run_cmd rm -rf "$repo_dir"
150+
run_cmd git clone --depth 1 --branch "$BRANCH" "$REPO_URL" "$repo_dir"
151+
fi
152+
116153
printf '%s\n' "$repo_dir"
117154
}
118155

docs/website/web_assets/installers/asrfacet-rb-installer-windows.ps1

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,32 @@ function Confirm-Requirements {
6565
}
6666
}
6767

68+
function Get-RequiredPaths {
69+
param([string]$SelectedMode)
70+
71+
$paths = @("install/windows.ps1")
72+
if ($SelectedMode -in @("install", "update", "test")) {
73+
$paths += @(
74+
"bin",
75+
"config",
76+
"lib",
77+
"man",
78+
"wordlists",
79+
"Gemfile",
80+
"Gemfile.lock",
81+
"asrfacet-rb.gemspec",
82+
"README.md",
83+
"LICENSE"
84+
)
85+
86+
if ($SelectedMode -eq "test") {
87+
$paths += "spec"
88+
}
89+
}
90+
91+
return $paths
92+
}
93+
6894
function Invoke-Step {
6995
param(
7096
[string]$CommandName,
@@ -111,11 +137,38 @@ try {
111137
}
112138

113139
$repoDir = Join-Path $WorkDir "source"
114-
Invoke-Step -CommandName "Cloning ASRFacet-Rb from GitHub" -Command {
115-
& git clone --depth 1 --branch $Branch $RepoUrl $repoDir
140+
Invoke-Step -CommandName "Cloning required ASRFacet-Rb files from GitHub" -Command {
141+
& git clone --depth 1 --filter=blob:none --sparse --branch $Branch $RepoUrl $repoDir
116142
if ($LASTEXITCODE -ne 0) {
117143
throw "git clone failed."
118144
}
145+
146+
Push-Location $repoDir
147+
try {
148+
$paths = Get-RequiredPaths -SelectedMode $selectedMode
149+
& git sparse-checkout init --no-cone
150+
if ($LASTEXITCODE -ne 0) {
151+
throw "git sparse-checkout init failed."
152+
}
153+
154+
& git sparse-checkout set --no-cone @paths
155+
if ($LASTEXITCODE -ne 0) {
156+
throw "git sparse-checkout set failed."
157+
}
158+
} catch {
159+
Pop-Location
160+
Write-Warn "Sparse checkout is unavailable in this git environment. Falling back to full shallow clone."
161+
Remove-Item -LiteralPath $repoDir -Recurse -Force -ErrorAction SilentlyContinue
162+
& git clone --depth 1 --branch $Branch $RepoUrl $repoDir
163+
if ($LASTEXITCODE -ne 0) {
164+
throw "git clone fallback failed."
165+
}
166+
return
167+
} finally {
168+
if ((Get-Location).Path -eq $repoDir) {
169+
Pop-Location
170+
}
171+
}
119172
}
120173

121174
$installScript = Join-Path $repoDir "install\windows.ps1"

0 commit comments

Comments
 (0)