On using yalc scripts

Yalc is proving to be a valuable tool because it enables us to test changes to a package in a using application without publishing to NPM. But when multiple developers are reviewing each other’s PRs it becomes pretty confusing quickly to get a local setup working properly. I recently had to review a complex change that touched several libraries and could only be tested together in the app (tc-create). Plus, I had to keep my own set of changes.

So I wrote a “yalc script” to do the job for me. When I needed to review the PR, I ran this one:

#!/bin/sh

BRANCH="zach-883-exit-prompt"
CURDIR=`pwd`
PROJDIR=`basename $CURDIR`

if [ "$PROJDIR" != "tc-create-app" ]
then
  echo "Script must be run from ./tc-create-app"
  exit
fi

echo Assumptions:
echo All project folders are at same level
echo All branch names for each project folder are the same 

echo ________________________________
echo Working on markdown-translatable
echo
cd ../markdown-translatable
git switch master
git pull 
git switch $BRANCH
git pull
yarn install
yalc publish

echo _________________________________
echo Working on datatable-translatable
echo
cd ../datatable-translatable
git switch master
git pull 
git switch $BRANCH
git pull
yalc remove --all
yalc link markdown-translatable
yarn install
yalc publish

echo ______________________________
echo Working on gitea-react-toolkit
echo
cd ../gitea-react-toolkit
git switch master
git pull 
git switch $BRANCH
git pull
yarn install
yalc publish

echo ________________________
echo Working on tc-create-app
echo
cd ../tc-create-app
git switch develop
git pull 
git switch $BRANCH
git pull
yalc remove --all
yalc link markdown-translatable
yalc link datatable-translatable
yalc link gitea-react-toolkit
yarn install
yarn start

Then when I was done, I ran mine to get me back to a working state where I left off before switching to review the PR:

#!/bin/sh

BRANCH="feature-cn-897-add-row-below-deleted-rows"
CURDIR=`pwd`
PROJDIR=`basename $CURDIR`

if [ "$PROJDIR" != "tc-create-app" ]
then
  echo "Script must be run from ./tc-create-app"
  exit
fi

echo Assumptions:
echo All project folders are at same level
echo All branch names for each project folder are the same 

echo _________________________________
echo Working on datatable-translatable
echo
cd ../datatable-translatable
git switch master
git pull 
git switch $BRANCH
git pull
yalc remove --all
yarn install
yalc publish


echo ________________________
echo Working on tc-create-app
echo
cd ../tc-create-app
echo First, remove any existing yalc links
yalc remove --all
git switch develop
git pull 

yalc link datatable-translatable
yarn install
yarn start

Might be helpful to store these in the issue itself for future reference. Thoughts?

1 Like

Great writeup Cecil. While this makes sense, I’m wondering if a video walk through might help visualize the need and the solution. If we find this as a common solution as we work on our RCLs to make changes in an app and see the impact with Yalc prior to publishing a new release, maybe we can make the scripts accept props for the branch name to be reuseable.