Replies: 9 comments
-
|
For anyone else struggling with the similar issue as mine and wants to update npm dependencies in every app or package of their turbo repo can use this. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @vaibhavmuchandi, thanks for the issue. We've been discussing some more integrations with package managers, so we can definitely add this as a potential feature. |
Beta Was this translation helpful? Give feedback.
-
|
Doesn't |
Beta Was this translation helpful? Give feedback.
-
|
There is Examples
Or run with no options to update everything in the whole monorepo, although this would include peerDependencies, overrides/resolutions, etc |
Beta Was this translation helpful? Give feedback.
-
|
Yes, it's pretty awesome too! |
Beta Was this translation helpful? Give feedback.
-
|
Thanks! There is |
Beta Was this translation helpful? Give feedback.
-
|
We definitely recommend |
Beta Was this translation helpful? Give feedback.
-
Yeah, mainly to change in the |
Beta Was this translation helpful? Give feedback.
-
|
I use the below script to update dependencies across my monorepo.. Scripts
#!/bin/bash
# Array of directories to look in
dirs_to_check=("packages" "apps")
# Array of dependencies to update
dependencies=(
"package1"
"package2"
)
# Find the absolute path to the monorepo's root directory
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
chmod +x "$DIR/find_monorepo_root.sh"
source "$DIR/find_monorepo_root.sh"
MONOREPO_ROOT=$(find_monorepo_root)
echo "👉 Monorepo root found at: $MONOREPO_ROOT"
# Function to update dependencies in a given package
update_dependencies() {
local sd_path=$1
echo "🔄 Updating dependencies in $sd_path"
if (cd "$sd_path" && pnpm update "${dependencies[@]/%/@latest}"); then
echo "✅ Successfully updated dependencies in $sd_path"
else
echo "❌ Failed to update dependencies in $sd_path"
fi
}
# Loop through specified directories and update dependencies in each sub dir
for dir in "${dirs_to_check[@]}"; do
sub_dir=$(ls -d "$MONOREPO_ROOT/$dir"/* 2>/dev/null)
for sd in $sub_dir; do
if [ -d "$sd" ]; then
echo "📦 Processing package: $sd"
if [ -f "$sd/package.json" ]; then
update_dependencies "$sd"
else
echo "⚠️ No package.json found in $sd, skipping..."
fi
else
echo "⚠️ Directory $sd does not exist, skipping..."
fi
done
done
echo "✅ Dependency updates completed."`find_monorepo_root.sh #!/bin/sh
# Function to check if a directory is a monorepo root
is_monorepo_root() {
local dir=$1
# [ -f "$dir/lerna.json" ] && return 0
[ -f "$dir/pnpm-workspace.yaml" ] && return 0
return 1
}
# Function to find the monorepo root
find_monorepo_root() {
local cwd=${1:-$(pwd)}
while [ "$cwd" != "/" ]; do
if is_monorepo_root "$cwd"; then
echo "$cwd"
return
fi
cwd=$(dirname "$cwd")
done
echo "❌ No monorepo root could be found upwards from the directory $1" >&2
exit 1
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Which project is this feature idea for?
Turborepo
Describe the feature you'd like to request
Currently, in Turbo Repo, when an npm dependency package gets an update, developers must manually update it in each app or package using the
pnpm updatecommand. I propose a feature that allows for global updating of npm dependencies across all apps and packages. This would streamline the update process, saving time and reducing the risk of inconsistencies.Describe the solution you'd like
I would like to see the implementation of a command or configuration option within Turbo Repo that allows developers to update npm dependencies across all apps and packages simultaneously. This could be a new command such as
turbo updateor an extension of the existing update functionality with a global option.Describe alternatives you've considered
An alternative solution could be to create a script that automates the current process of individually updating dependencies in each app or package. However, integrating this feature directly into Turbo Repo would provide a more robust and user-friendly solution, aligning with the tool's goal of simplifying development workflows.
Beta Was this translation helpful? Give feedback.
All reactions