Skip to content
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

Adjust pnpm to support Sail alias #607

Merged
merged 5 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions bin/sail
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ function display_help {
echo " ${GREEN}sail npx${NC} Run a npx command"
echo " ${GREEN}sail npm run prod${NC}"
echo
echo "${YELLOW}PNPM Commands:${NC}"
echo " ${GREEN}sail pnpm ...${NC} Run a pnpm command"
echo " ${GREEN}sail pnpx${NC} Run a pnpx command"
echo " ${GREEN}sail pnpm run prod${NC}"
echo
echo "${YELLOW}Yarn Commands:${NC}"
echo " ${GREEN}sail yarn ...${NC} Run a Yarn command"
echo " ${GREEN}sail yarn run prod${NC}"
Expand Down Expand Up @@ -391,6 +396,30 @@ elif [ "$1" == "npx" ]; then
sail_is_not_running
fi

# Proxy PNPM commands to the "pnpm" binary on the application container...
elif [ "$1" == "pnpm" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" pnpm "$@")
else
sail_is_not_running
fi

# Proxy PNPX commands to the "pnpx" binary on the application container...
elif [ "$1" == "pnpx" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" pnpx "$@")
else
sail_is_not_running
fi

# Proxy YARN commands to the "yarn" binary on the application container...
elif [ "$1" == "yarn" ]; then
shift 1
Expand Down
2 changes: 1 addition & 1 deletion runtimes/8.2/Dockerfile
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to put the pnpm install command on a separate line after the long-running command, like so
RUN curl -fsSL https://get.pnpm.io/install.sh | bash
this will make rebuilding faster because it allows Docker to run the long-running command from the cache

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this way when you run sail shell, the pnpm command will not be available because it's installed only for the root user.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN apt-get update \
&& curl -sLS https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g npm \
&& curl -fsSL https://get.pnpm.io/install.sh | bash - \
&& npm install -g pnpm \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /etc/apt/keyrings/yarn.gpg >/dev/null \
&& echo "deb [signed-by=/etc/apt/keyrings/yarn.gpg] https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
&& curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /etc/apt/keyrings/pgdg.gpg >/dev/null \
Expand Down