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

feat(node): use versioned folders #210

Merged
merged 2 commits into from
Dec 6, 2021
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
35 changes: 24 additions & 11 deletions src/usr/local/buildpack/tools/lerna.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,32 @@ set -e

check_command node

if [[ $EUID -eq 0 ]]; then
unset NPM_CONFIG_PREFIX
fi
tool_path=$(find_tool_path)

npm install -g lerna@${TOOL_VERSION}
function update_env () {
reset_tool_env
export_tool_path "${1}/bin"
}

lerna --version
if [[ -z "${tool_path}" ]]; then
INSTALL_DIR=$(get_install_dir)
base_path=${INSTALL_DIR}/${TOOL_NAME}
tool_path=${base_path}/${TOOL_VERSION}

mkdir -p ${tool_path}

if [[ $EUID -eq 0 ]]; then
shell_wrapper lerna
NPM_CONFIG_PREFIX=$tool_path npm install --cache /tmp/empty-cache -g ${TOOL_NAME}@${TOOL_VERSION}

# Clean download cache
NPM_CONFIG_PREFIX=$tool_path npm cache clean --force
# Clean node-gyp cache
rm -rf $HOME/.cache /tmp/empty-cache

update_env ${tool_path}
shell_wrapper ${TOOL_NAME}
else
echo "Already installed, resetting env"
update_env ${tool_path}
fi

# Clean download cache
npm cache clean --force
# Clean node-gyp cache
rm -rf /root/.cache
lerna --version
35 changes: 24 additions & 11 deletions src/usr/local/buildpack/tools/pnpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,32 @@ set -e

check_command node

if [[ $EUID -eq 0 ]]; then
unset NPM_CONFIG_PREFIX
fi
tool_path=$(find_tool_path)

npm install -g pnpm@${TOOL_VERSION}
function update_env () {
reset_tool_env
export_tool_path "${1}/bin"
}

pnpm --version
if [[ -z "${tool_path}" ]]; then
INSTALL_DIR=$(get_install_dir)
base_path=${INSTALL_DIR}/${TOOL_NAME}
tool_path=${base_path}/${TOOL_VERSION}

mkdir -p ${tool_path}

if [[ $EUID -eq 0 ]]; then
shell_wrapper pnpm
NPM_CONFIG_PREFIX=$tool_path npm install --cache /tmp/empty-cache -g ${TOOL_NAME}@${TOOL_VERSION}

# Clean download cache
NPM_CONFIG_PREFIX=$tool_path npm cache clean --force
# Clean node-gyp cache
rm -rf $HOME/.cache /tmp/empty-cache

update_env ${tool_path}
shell_wrapper ${TOOL_NAME}
else
echo "Already installed, resetting env"
update_env ${tool_path}
fi

# Clean download cache
npm cache clean --force
# Clean node-gyp cache
rm -rf /root/.cache
pnpm --version
35 changes: 25 additions & 10 deletions src/usr/local/buildpack/tools/yarn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,32 @@ set -e

check_command node

if [[ $EUID -eq 0 ]]; then
unset NPM_CONFIG_PREFIX
fi
tool_path=$(find_tool_path)

npm install -g yarn@${TOOL_VERSION}
function update_env () {
reset_tool_env
export_tool_path "${1}/bin"
}

yarn --version
if [[ -z "${tool_path}" ]]; then
INSTALL_DIR=$(get_install_dir)
base_path=${INSTALL_DIR}/${TOOL_NAME}
tool_path=${base_path}/${TOOL_VERSION}

mkdir -p ${tool_path}

NPM_CONFIG_PREFIX=$tool_path npm install --cache /tmp/empty-cache -g ${TOOL_NAME}@${TOOL_VERSION}

shell_wrapper yarn
# Clean download cache
NPM_CONFIG_PREFIX=$tool_path npm cache clean --force
# Clean node-gyp cache
rm -rf $HOME/.cache /tmp/empty-cache

# Clean download cache
npm cache clean --force
# Clean node-gyp cache
rm -rf /root/.cache
update_env ${tool_path}
shell_wrapper ${TOOL_NAME}
else
echo "Already installed, resetting env"
update_env ${tool_path}
fi

yarn --version
6 changes: 5 additions & 1 deletion test/node/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,18 @@ USER root
RUN install-tool yarn 1.22.17

# renovate: datasource=npm
RUN install-npm lerna 4.0.0
RUN install-tool lerna 4.0.0

USER 1000

RUN set -ex; \
[ "$(command -v yarn)" = "/usr/local/bin/yarn" ] && echo "works" || exit 1; \
yarn --version

RUN set -ex; \
[ "$(command -v lerna)" = "/usr/local/bin/lerna" ] && echo "works" || exit 1; \
lerna --version

#--------------------------------------
# test: pnpm
#--------------------------------------
Expand Down