Created
December 13, 2025 01:03
-
-
Save justin-hackin/29b0fe4ea9aaa75e7df41e6022f6d981 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # This script was written to serve an alternative to the now-defunct gitpkg service | |
| # It uses degit to fetch a repo and then creates patches for `patch-package` | |
| pwd | |
| packages=("shared" "calendar" "theme-shadcn") | |
| project_root="$(git rev-parse --show-toplevel)" | |
| temp_folder="$project_root/degit-temp" | |
| cd "$project_root" || exit | |
| echo "Project root: $project_root" | |
| npx degit --force justin-hackin/schedule-x#build "$temp_folder" | |
| for package in "${packages[@]}"; do | |
| scoped_package="@schedule-x/$package" | |
| echo "Scoped package: $scoped_package" | |
| dist_dir="$temp_folder/packages/$package/dist" | |
| destination="$project_root/node_modules/$scoped_package" | |
| cd "$project_root" || exit | |
| echo "Copying : $dist_dir TO $destination " | |
| cp -Rf "$dist_dir" "$destination" | |
| echo "Patching package: $scoped_package" | |
| npx patch-package "$scoped_package" | |
| echo "Remove postinstall from package.json file in package (file preserved at tmp.json)" | |
| cd "$destination" || { echo "Failed to enter directory $destination"; exit 1; } | |
| # Remove the postinstall script from package.json | |
| cp package.json package.bak.json | |
| jq 'del(.scripts.postinstall)' package.json > package.no-post.json | |
| mv -f package.no-post.json package.json | |
| # Go back to the previous directory | |
| done | |
| npm i | |
| # Restore the package.json files | |
| for package in "${packages[@]}"; do | |
| scoped_package="@schedule-x/$package" | |
| echo "Scoped package: $scoped_package" | |
| dist_dir="$temp_folder/packages/$package/dist/" | |
| destination="$project_root/node_modules/$scoped_package" | |
| cd "$destination" || { echo "Failed to enter directory $destination"; exit 1; } | |
| # Restore the original package.json | |
| mv -f package.bak.json package.json | |
| done | |
| rm -Rf "$temp_folder" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment