Skip to content
This repository was archived by the owner on Sep 25, 2025. It is now read-only.

Commit 73dbbf4

Browse files
committed
fix: install.sh
1 parent b93cbc0 commit 73dbbf4

File tree

1 file changed

+37
-18
lines changed

1 file changed

+37
-18
lines changed

packages/public/install.sh

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,18 @@ log_debug() {
2929

3030
fetch_directory_contents() {
3131
local repo_path=$1
32-
curl -sL \
33-
-H "Accept: application/vnd.github+json" \
34-
-H "Authorization: Bearer $GH_TOKEN" \
35-
-H "X-GitHub-Api-Version: 2022-11-28" \
36-
"https://api.github.com/repos/$GH_REPO/contents/$repo_path"
32+
response=$(curl -sL -w "%{http_code}" -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GH_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/$GH_REPO/contents/$repo_path")
33+
34+
# Extract the HTTP status code
35+
http_code=$(echo "$response" | tail -n1)
36+
37+
if [ "$http_code" -eq 404 ]; then
38+
echo "Error: Directory not found at path '$repo_path'." >&2
39+
exit 1
40+
fi
41+
42+
# Extract the response body (JSON content)
43+
echo "$response" | head -n -1
3744
}
3845

3946
rewrite_path() {
@@ -72,7 +79,7 @@ download_files() {
7279
local local_path=$2
7380
local mode=$3
7481
local case_option=$4
75-
local max_jobs=5 # Limit the number of parallel jobs
82+
local max_jobs=5 # Limit the number of parallel jobs
7683
local job_count=0
7784

7885
response=$(fetch_directory_contents "$repo_path")
@@ -96,6 +103,12 @@ download_files() {
96103
continue
97104
fi
98105

106+
# Skip specific files
107+
if [[ "$name" == "package.json" || "$name" == "tsconfig.json" || "$name" == "tsconfig.lib.json" || "$name" == "tsconfig.test.json" || "$name" == "vitest.config.ts" ]]; then
108+
log_debug "Skipping file: $name"
109+
continue
110+
fi
111+
99112
if [ "$type" == "dir" ]; then
100113
if [[ "$name" == "__snapshots__" ]]; then
101114
continue
@@ -150,8 +163,8 @@ download_files() {
150163

151164
# Manage the job queue
152165
((job_count++))
153-
if (( job_count >= max_jobs )); then
154-
wait -n # Wait for at least one job to finish before continuing
166+
if ((job_count >= max_jobs)); then
167+
wait -n # Wait for at least one job to finish before continuing
155168
((job_count--))
156169
fi
157170
done
@@ -220,10 +233,10 @@ search_relations() {
220233

221234
install_component() {
222235
local component=$1
223-
local local_path=$2
224-
local mode=$3
225-
local case_option=$4
226-
local repo_path="src"
236+
local repo_path=$2
237+
local local_path=$3
238+
local mode=$4
239+
local case_option=$5
227240

228241
all_relations=$(fetch_relations)
229242

@@ -235,10 +248,10 @@ install_component() {
235248
}
236249

237250
install_components() {
238-
local local_path=$1
239-
local mode=$2
240-
local case_option=$3
241-
local repo_path="src"
251+
local repo_path=$1
252+
local local_path=$2
253+
local mode=$3
254+
local case_option=$4
242255

243256
download_files "$repo_path" "$local_path" "$mode" "$case_option"
244257
}
@@ -299,9 +312,15 @@ main() {
299312
validate_options
300313

301314
if [ -n "$COMPONENT" ]; then
302-
install_component "$COMPONENT" "$LOCAL_PATH" "$MODE" "$CASE_OPTION"
315+
install_component "$COMPONENT" "$REPO_PATH" "$LOCAL_PATH" "$MODE" "$CASE_OPTION"
303316
else
304-
install_components "$LOCAL_PATH" "$MODE" "$CASE_OPTION"
317+
install_components "$REPO_PATH" "$LOCAL_PATH" "$MODE" "$CASE_OPTION"
318+
fi
319+
320+
# Check if the previous command failed
321+
if [ $? -ne 0 ]; then
322+
echo "Error: Installation failed." >&2
323+
exit 1
305324
fi
306325

307326
# Remove empty directories

0 commit comments

Comments
 (0)