Skip to content

Commit d461f05

Browse files
committed
ci: fix logic for sub folders
1 parent 20adfad commit d461f05

File tree

4 files changed

+49
-6
lines changed

4 files changed

+49
-6
lines changed

scripts/patch-repo.sh

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,56 @@ if [ ! -f "$TAR_FILE" ]; then
2020
exit 1
2121
fi
2222

23+
if [ ! -r "$TAR_FILE" ]; then
24+
echo "Error: Tar file $TAR_FILE is not readable"
25+
exit 1
26+
fi
27+
2328
if [ ! -d "$TARGET_DIR" ]; then
2429
echo "Error: Target directory $TARGET_DIR does not exist"
2530
exit 1
2631
fi
2732

28-
# Extract tar archive
29-
tar zxvvf "$TAR_FILE" -C "$(dirname "$TARGET_DIR")"
33+
# Verify tar file is valid before proceeding
34+
if ! tar -tzf "$TAR_FILE" >/dev/null 2>&1; then
35+
echo "Error: Tar file $TAR_FILE is corrupted or invalid"
36+
exit 1
37+
fi
38+
39+
# Determine how many leading components to strip from the tarball
40+
# We count the number of directory separators in the first entry
41+
# e.g., "vue/v2/" -> 2 slashes -> strip 2, "react/" -> 1 slash -> strip 1
42+
# Use a temporary file to avoid broken pipe errors when piping tar output
43+
TEMP_LIST=$(mktemp)
44+
trap "rm -f $TEMP_LIST" EXIT
45+
if ! tar -tf "$TAR_FILE" > "$TEMP_LIST" 2>/dev/null; then
46+
echo "Error: Could not read tar file $TAR_FILE"
47+
exit 1
48+
fi
49+
FIRST_ENTRY=$(head -n 1 "$TEMP_LIST")
50+
if [ -z "$FIRST_ENTRY" ]; then
51+
echo "Error: Tar file $TAR_FILE appears to be empty"
52+
exit 1
53+
fi
54+
STRIP_COMPONENTS=$(echo "$FIRST_ENTRY" | tr -cd '/' | wc -c)
55+
rm -f "$TEMP_LIST"
56+
trap - EXIT
57+
58+
# Clean up target directory except for .git and node_modules to ensure a clean sync
59+
# This allows 'git add -A' to detect deletions
60+
find "$TARGET_DIR" -mindepth 1 -maxdepth 1 ! -name ".git" ! -name "node_modules" -exec rm -rf {} +
61+
62+
# Extract tar archive directly into the target directory, stripping the prefix
63+
# Use explicit error handling to catch any extraction failures
64+
if ! tar zxf "$TAR_FILE" -C "$TARGET_DIR" --strip-components="${STRIP_COMPONENTS// /}"; then
65+
echo "Error: Failed to extract tar file $TAR_FILE to $TARGET_DIR"
66+
exit 1
67+
fi
3068

3169
# Add all changes and commit
3270
cd "$TARGET_DIR"
3371
git add -A
34-
if git commit -m "chore: sync with web-shim-codegen v$VERSION"; then
72+
if git commit -m "build: sync with web-shim-codegen v$VERSION"; then
3573
echo "$REPO_NAME repository has been updated"
3674
else
3775
echo "$REPO_NAME repository has NOT been updated, no changes to commit"

src/static/.releaserc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@
6969
"section": "Documentation",
7070
"hidden": false
7171
},
72+
{
73+
"type": "build",
74+
"section": "Build System",
75+
"hidden": false
76+
},
7277
{
7378
"type": "deps",
7479
"section": "Dependency Updates",

src/static/react/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/static/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-onesignal",
3-
"version": "3.4.0",
3+
"version": "3.4.1",
44
"description": "React OneSignal Module: Make it easy to integrate OneSignal with your React App!",
55
"contributors": [
66
{

0 commit comments

Comments
 (0)