]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/eg2/reversion.sh
LP1908763 Survey column sorting broken
[Evergreen.git] / Open-ILS / src / eg2 / reversion.sh
1 #!/bin/bash
2 # Author: Bill Erickson <berickxx@gmail.com>
3 #
4 # Script to rebuild the set of Angular dependencies.
5 # 1. Remove node_modules
6 # 2. Remove dependencies and devDependencies from package.json
7 # 3. Install @angular/core using the requested version of angular.
8 # 4. Reinstall dependencies and devDependencies
9 #
10 # Building in this fashion, where we start with a single Angular package
11 # allows the other packages to better determine the version to use.
12
13 # Script requires 'jq' program (sudo apt-get install jq) for 
14 # parsing and manipulating JSON.
15 # ----------------------------------------------------------------------------
16 set -euo pipefail
17 ANGULAR_VERSION="" # Example ^8.0.0
18
19 function usage {
20     cat <<USAGE
21         
22         Synopsis:
23
24             $0 -v "^8.0.0"
25
26         Options:
27
28             -v Angular version string
29 USAGE
30
31     exit 0;
32 }
33
34 while getopts "v:h" opt; do
35     case $opt in
36         v) ANGULAR_VERSION="$OPTARG";;
37         h) usage;
38     esac
39 done;
40
41 if [ -z "$ANGULAR_VERSION" ]; then
42     echo "Angular version required"
43     usage;
44 fi;
45
46 echo "Removing node_modules"
47 rm -rf ./node_modules
48
49 echo "Removing package-lock.json"
50 rm -f package-lock.json
51
52 # Exctract the dependencies from package.json
53 DEPS=$(jq '.dependencies | keys' package.json | tr '[],"' ' ' | xargs);
54 DEV_DEPS=$(jq '.devDependencies | keys' package.json | tr '[],"' ' ' | xargs);
55
56 # Remove deps from package.json
57 jq '.devDependencies={} | .dependencies={}' package.json > package.wip.json
58 mv package.wip.json package.json
59
60 # Start by installing the version of Angular we want to use
61 npm install @angular/cli@$ANGULAR_VERSION @angular/core@$ANGULAR_VERSION
62
63 # Then let NPM figure out the versioning for the rest.
64
65 npm install --save $DEPS
66 npm install --save-dev $DEV_DEPS
67
68