Skip to content

Instantly share code, notes, and snippets.

@jankapunkt
Last active March 18, 2020 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jankapunkt/167afd46f3891da11738777fa9207393 to your computer and use it in GitHub Desktop.
Save jankapunkt/167afd46f3891da11738777fa9207393 to your computer and use it in GitHub Desktop.
Update Meteor core + packages + npm outdated packages
#!/usr/bin/env bash
# Author: Jan Küster
# License: MIT
# Description:
# This optional script checks for the updated files related to
# the update script and commits their changes using some default messaged.
# -----------------------------------------------------------------------------
# Step 4: check for changed files and create respective commit messages
# -----------------------------------------------------------------------------
commit_maybe () {
commit_message=$1
shift
file_names=""
for var in "$@"
do
found=$(git diff --name-only --diff-filter=M | grep -c ${var})
if [ "$found" -ge 1 ]; then
file_names="${file_names} ${var}"
fi
done
if [ ! -z "$file_names" ]; then
# git commit ${file_name} -m ${commit_message}
echo "git commit ${file_names} -m \"${commit_message}\""
fi
}
# commit new meteor release version
NEW_METEOR_VERSION=$(cat ./.meteor/release | cut -d'@' -f2 )
commit_maybe "meteor core updated to ${NEW_METEOR_VERSION}" .meteor/release .meteor/.finished-upgraders
commit_maybe "meteor packages updated" .meteor/packages .meteor/versions
commit_maybe "npm packages updated" package.json package-lock.json
#!/usr/bin/env bash
# Author: Jan Küster
# License: MIT
# Description: This script updated the Meteor core + all Meteor packages + all outdated npm packages.
# -----------------------------------------------------------------------------
# Step 1: update meteor core and related packages
# -----------------------------------------------------------------------------
# pass all package dirs as parameters to the script call or put them in here
PACKAGE_DIRS="$@"
METEOR_PACKAGE_DIRS=${PACKAGE_DIRS} meteor update --all-packages
# -----------------------------------------------------------------------------
# Step 2: update all outdated npm packages to the latest
# thanks to: https://stackoverflow.com/a/55406675/3098783
# -----------------------------------------------------------------------------
meteor npm install $(meteor npm outdated | cut -d' ' -f 1 | sed '1d' | xargs -I '$' echo '$@latest' | xargs echo)
# -----------------------------------------------------------------------------
# Step 3: clean installed modules because some modules are broken
# after an update (mostly related to modules that needs to be built)
# -----------------------------------------------------------------------------
rm -rf ./node_modules
meteor npm install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment