Skip to content

Commit 4cf0f2e

Browse files
committed
ci: fix logic for sub folders
also update files property to just include dist
1 parent 20adfad commit 4cf0f2e

File tree

10 files changed

+60
-29
lines changed

10 files changed

+60
-29
lines changed

.github/actions/create-pr/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ runs:
3232
with:
3333
github-token: ${{ inputs.github_token }}
3434
script: |
35-
const title = 'ci: sync with web-shim-codegen v' + '${{ inputs.package_version }}';
35+
const title = 'build: sync with web-shim-codegen v' + '${{ inputs.package_version }}';
3636
const body = 'This update was generated by the GitHub CD action.';
3737
3838
// Check if a PR already exists for this branch

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

3171
# Add all changes and commit
3272
cd "$TARGET_DIR"
3373
git add -A
34-
if git commit -m "chore: sync with web-shim-codegen v$VERSION"; then
74+
if git commit -m "build: sync with web-shim-codegen v$VERSION"; then
3575
echo "$REPO_NAME repository has been updated"
3676
else
3777
echo "$REPO_NAME repository has NOT been updated, no changes to commit"

src/scaffolds/angular-workspace/projects/onesignal-ngx/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@
3535
"bundles/",
3636
"lib/",
3737
"fesm2015/",
38+
"esm2015/",
3839
"*.d.ts",
39-
"*.metadata.json",
40-
"LICENSE",
41-
"README.md",
42-
"MigrationGuide.md"
40+
"*.metadata.json"
4341
]
4442
}

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: 2 additions & 6 deletions
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
{
@@ -53,11 +53,7 @@
5353
"vitest": "^3.0.9"
5454
},
5555
"files": [
56-
"dist",
57-
"README.md",
58-
"LICENSE",
59-
"CHANGELOG.md",
60-
"MigrationGuide.md"
56+
"dist"
6157
],
6258
"keywords": [
6359
"onesignal",

src/static/vue/v2/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@
2727
"typescript": "^4.6.3"
2828
},
2929
"files": [
30-
"dist",
31-
"README.md",
32-
"LICENSE",
33-
"CHANGELOG.md",
34-
"MigrationGuide.md"
30+
"dist"
3531
],
3632
"keywords": [
3733
"onesignal",

src/static/vue/v3/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@
3131
"typescript": "^4.6.3"
3232
},
3333
"files": [
34-
"dist",
35-
"README.md",
36-
"LICENSE",
37-
"CHANGELOG.md",
38-
"MigrationGuide.md"
34+
"dist"
3935
],
4036
"keywords": [
4137
"onesignal",

0 commit comments

Comments
 (0)