Skip to content

Commit 2dc1c6c

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

File tree

6 files changed

+53
-9
lines changed

6 files changed

+53
-9
lines changed

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.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "web-shim-codegen",
3-
"version": "3.0.7",
3+
"version": "3.0.8",
44
"description": "Used to build Web SDK libraries for various web frameworks",
55
"main": "index.js",
66
"scripts": {

scripts/patch-repo.sh

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,57 @@ 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, node_modules, and CHANGELOG.md to ensure a clean sync
59+
# CHANGELOG.md is preserved because it's generated by semantic-release, not included in the tarball
60+
# This allows 'git add -A' to detect deletions
61+
find "$TARGET_DIR" -mindepth 1 -maxdepth 1 ! -name ".git" ! -name "node_modules" ! -name "CHANGELOG.md" -exec rm -rf {} +
62+
63+
# Extract tar archive directly into the target directory, stripping the prefix
64+
# Use explicit error handling to catch any extraction failures
65+
if ! tar zxf "$TAR_FILE" -C "$TARGET_DIR" --strip-components="${STRIP_COMPONENTS// /}"; then
66+
echo "Error: Failed to extract tar file $TAR_FILE to $TARGET_DIR"
67+
exit 1
68+
fi
3069

3170
# Add all changes and commit
3271
cd "$TARGET_DIR"
3372
git add -A
34-
if git commit -m "chore: sync with web-shim-codegen v$VERSION"; then
73+
if git commit -m "build: sync with web-shim-codegen v$VERSION"; then
3574
echo "$REPO_NAME repository has been updated"
3675
else
3776
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)