-
Notifications
You must be signed in to change notification settings - Fork 0
/
force-update-project-boilerplate.sh
executable file
·59 lines (41 loc) · 1.83 KB
/
force-update-project-boilerplate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
if [ -f "./.git" ]
then
echo -e "This project is a Git Submodule!
If you want to run a forced update on a Git Submodule, use the update-nested-project-boilerplate.sh script."
elif [ ! -d "./.git/" ]
then
echo -e "This command is only to be used when the project is in the root directory of a Git repository"
else
echo "Paste the URL of the git repository where the boilerplate is"
read git_url
echo "What is the name of the git branch where the updates are?"
read git_branch
echo "Updating..."
mv ./.git ./.git-bkp
git init
git add .
git commit -m "Before update"
git remote add boilerplate $git_url
git fetch boilerplate $git_branch
git merge "boilerplate/${git_branch}" --allow-unrelated-histories -X theirs
rm -rf ./.git/
mv ./.git-bkp ./.git
git checkout -- package-lock.json **/package-lock.json
echo "
-----
-----
-----
----- BEFORE CONTINUING
- CHECK IF THE UPDATE DIDN'T FAILED HALFWAY
- Make sure the current git repository is again pointing to your project's repository and NOT to the boilerplate repository
- You can do this by running 'git remote' and checking that there is no remote called 'boilerplate'
- If the 'boilerplate' remote still exists
- Delete the '.git/' directory (in the project's root directory) and rename the '.git-bkp' directory back to '.git'
- Pick the updates you want to add to the project
- Run 'npm run install:all' to update the 'package-lock.json' files with the dependencies changes
- Check if any of the changes made by the updates require a new migration to be written
- Run 'npm run integrity-check:all' to make sure the updates didn't break any part of your project
- IF YOU WANT TO ABORT the update, just discard the changes as you normally would with your work
- To finalize the update, commit everything as you would do with regular work"
fi