-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add package-link file to storefront #745
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
026ad5b
chore(deps): Bump ini from 1.3.5 to 1.3.7
dependabot[bot] 65c6ecd
chore: add package-link file to storefront
kieckhafer 994159f
chore: add package-unlink
kieckhafer 0d25bc4
update docker-compose to use base image which installs yalc
kieckhafer 1256272
add package-update bin script
kieckhafer d113561
add correct permissions on file
kieckhafer c8b949c
fix: merge trunk to pass tests
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,8 @@ build | |
/reports | ||
|
||
docker-compose.override.yml | ||
|
||
# Yalc | ||
.yalc/ | ||
yalc.lock | ||
yalc-packages |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Please Use Google Shell Style: https://google.github.io/styleguide/shell.xml | ||
|
||
# ---- Start unofficial bash strict mode boilerplate | ||
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | ||
set -o errexit # always exit on error | ||
set -o errtrace # trap errors in functions as well | ||
set -o pipefail # don't ignore exit codes when piping output | ||
set -o posix # more strict failures in subshells | ||
# set -x # enable debugging | ||
|
||
IFS="$(printf "\n\t")" | ||
# ---- End unofficial bash strict mode boilerplate | ||
|
||
package_name=$1 | ||
package_path=$2 | ||
yalc_packages_file_name="yalc-packages" | ||
container_id="$(docker-compose ps -q web)" | ||
container_copied_packages_path="/home/node/copied-packages" | ||
|
||
if [[ -z "${package_name}" ]]; then | ||
if ! [[ -f "$yalc_packages_file_name" ]]; then | ||
echo "Yalc packages file doesn't exist. Creating..." | ||
cp "${yalc_packages_file_name}.example" ${yalc_packages_file_name} | ||
fi | ||
|
||
echo "Reading package list from ${yalc_packages_file_name}" | ||
|
||
while IFS== read -r path val; do | ||
package_path="$path" | ||
package_name="$(node -p -e "JSON.parse(process.argv[1]).name" "$(cat ${package_path}/package.json)")" | ||
is_enabled="$val" | ||
|
||
if [[ $package_name ]]; then | ||
if [[ $is_enabled == "true" ]]; then | ||
container_destination_path="${container_copied_packages_path}/${package_name}" | ||
|
||
echo "Copying `${package_path}` package code into container to ${container_destination_path}..." | ||
docker exec ${container_id} sh -c "mkdir -p ${container_destination_path}" | ||
docker cp "${package_path}/." "${container_id}:${container_destination_path}" | ||
|
||
# Then yalc link into this project | ||
echo "Linking package ${package_name} into Example Storefront..." | ||
docker exec ${container_id} sh -c "cd ${container_destination_path} && yalc push" | ||
docker exec ${container_id} sh -c "cd /usr/local/src/app && yalc link ${package_name}" | ||
else | ||
echo "Unlinking package ${package_name} from Example Storefront..." | ||
docker exec ${container_id} sh -c "cd /usr/local/src/app && yalc remove ${package_name}" | ||
docker exec ${container_id} sh -c "rm -rf /usr/local/src/app/node_modules/${package_name}" | ||
fi | ||
fi | ||
done < "$yalc_packages_file_name" | ||
|
||
echo "Updating packages..." | ||
docker exec ${container_id} sh -c "cd /usr/local/src/app && npm i" | ||
docker exec ${container_id} sh -c "cd /usr/local/src/app && yalc update" | ||
else | ||
container_destination_path="${container_copied_packages_path}/${package_name}" | ||
|
||
if [[ -z "${package_path}" ]]; then | ||
package_name_without_org="${package_name/#@reactioncommerce\/}" | ||
package_path="../dev-plugins/${package_name_without_org}" | ||
full_package_path="$(cd ${package_path} && pwd)" | ||
echo "\nUsing local package path ${full_package_path}" | ||
echo "If this is not correct, specify the correct path as the second argument.\n" | ||
fi | ||
|
||
echo "Copying `${package_path}` package code into container..." | ||
docker-compose exec web sh -c "mkdir -p ${container_destination_path}" | ||
docker cp "${package_path}/." "${container_id}:${container_destination_path}" | ||
|
||
# Then yalc link into this project | ||
echo "Linking package into Example Storefront..." | ||
docker-compose exec web sh -c "cd ${container_destination_path} && yalc push" | ||
docker-compose exec web sh -c "cd /usr/local/src/app && yalc link ${package_name}" | ||
fi | ||
|
||
# Fool nodemon into thinking something has changed so that it restarts. | ||
# Touch first file found in /pages with .js extension | ||
echo "Restarting Example Storefront..." | ||
docker-compose exec web sh -c "touch -c $(ls ./pages/*.js | head -n1)" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Please Use Google Shell Style: https://google.github.io/styleguide/shell.xml | ||
|
||
# ---- Start unofficial bash strict mode boilerplate | ||
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | ||
set -o errexit # always exit on error | ||
set -o errtrace # trap errors in functions as well | ||
set -o pipefail # don't ignore exit codes when piping output | ||
set -o posix # more strict failures in subshells | ||
# set -x # enable debugging | ||
|
||
IFS="$(printf "\n\t")" | ||
# ---- End unofficial bash strict mode boilerplate | ||
|
||
package_name=$1 | ||
|
||
# Unlink the yalc dependency, remove the package drectory and npm install | ||
echo "Unlinking package from Example Storefront..." | ||
docker-compose exec web sh -c "cd /usr/local/src/app && yalc remove ${package_name}" | ||
docker-compose exec web sh -c "rm -rf /usr/local/src/app/node_modules/${package_name} && npm i" | ||
docker-compose exec web sh -c "cd /usr/local/src/app && yalc update" | ||
|
||
# Fool nodemon into thinking something has changed so that it restarts. | ||
# Touch first file found in /pages with .js extension | ||
echo "Restarting Example Storefront..." | ||
docker-compose exec web sh -c "touch -c $(ls ./pages/*.js | head -n1)" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Please Use Google Shell Style: https://google.github.io/styleguide/shell.xml | ||
|
||
# ---- Start unofficial bash strict mode boilerplate | ||
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | ||
set -o errexit # always exit on error | ||
set -o errtrace # trap errors in functions as well | ||
set -o pipefail # don't ignore exit codes when piping output | ||
set -o posix # more strict failures in subshells | ||
# set -x # enable debugging | ||
|
||
IFS="$(printf "\n\t")" | ||
# ---- End unofficial bash strict mode boilerplate | ||
|
||
# Unlink the yalc dependency, remove the package drectory and npm install | ||
echo "Updating package from Example Storefront..." | ||
docker-compose exec web sh -c "cd /usr/local/src/app && yalc update" | ||
|
||
# Fool nodemon into thinking something has changed so that it restarts. | ||
# Touch first file found in /src with .js extension | ||
echo "Restarting Example Storefront..." | ||
docker-compose exec web sh -c "touch -c $(ls ./src/*.js | head -n1)" |
This file contains 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
This file contains 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I this file needs execute permissions.