-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupgrade.sh
More file actions
executable file
·73 lines (66 loc) · 2.34 KB
/
upgrade.sh
File metadata and controls
executable file
·73 lines (66 loc) · 2.34 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env bash
set -euo pipefail
# Update the git submodules.
if [ -x "$(command -v git)" ]; then
if [ -d ".git" ]; then
echo "Updating git submodules..."
git submodule update --init --recursive
else
echo "No git repository found, skipping submodule update"
fi
else
echo "git is not installed, skipping submodule update"
fi
# Check if the `.pre-commit-config.yaml` file exists and run `pre-commit autoupdate`.
if [ -x "$(command -v pre-commit)" ]; then
if [ -f ".pre-commit-config.yaml" ]; then
echo "Updating pre-commit hooks..."
pre-commit autoupdate
else
echo ".pre-commit-config.yaml not found, skipping pre-commit autoupdate"
fi
else
echo "pre-commit is not installed, skipping pre-commit autoupdate"
fi
if [ -x "$(command -v nix)" ]; then
# Check if there is a flake.nix file
if [ -f "flake.nix" ]; then
echo "Found flake.nix, running nix flake update..."
NIX_CONFIG="experimental-features = nix-command flakes
access-tokens = github.com=$(gh auth token)" nix flake update
else
echo "flake.nix not found, skipping nix flake update"
fi
else
echo "Nix is not installed, skipping flake update"
fi
if [ -x "$(command -v go)" ]; then
# Check for a `go.mod` file and run `go mod tidy`.
if [ -f "go.mod" ]; then
echo "Found go.mod, running go mod tidy..."
go mod tidy
# Update the Go dependencies.
echo "Updating Go dependencies..."
go get -u ./...
else
echo "go.mod not found, skipping go mod tidy"
fi
else
echo "Go is not installed, skipping Go dependency update"
fi
if [ -x "$(command -v npm)" ]; then
# Do a recursive check for `package.json` files for each directory execute a set of commands.
find . -name "package.json" -execdir sh -c '
echo "Found package.json in $(pwd), running npm install..."
npm install npm-check-updates && ncu -u || echo "npm-check-updates is not installed, skipping"
npm update && npm install
echo "Installing npm-check-updates..."
echo "Running npm audit fix..."
npm audit fix
echo "Running npm run build..."
npm run build || echo "npm run build failed, skipping"
' \;
echo "All npm packages installed and built."
else
echo "npm is not installed, skipping npm install"
fi