-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
81 lines (73 loc) · 2.5 KB
/
Copy pathrun.sh
File metadata and controls
81 lines (73 loc) · 2.5 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
74
75
76
77
78
79
80
81
#!/usr/bin/env bash
set -e
show_help() {
echo "Sage-Code SCL Project Maintenance Wrapper"
echo "Usage: ./run.sh [command] [options]"
echo ""
echo "Commands:"
echo " clean Clean build artifacts (npm run clean)"
echo " build Build static website (npm run build)"
echo " rebuild Clean and perform a full build (npm run clean && npm run build:full)"
echo " test Run local tests (npm run test:local)"
echo " commit Stage changes and commit with message"
echo " Usage: ./run.sh commit \"your commit message\""
echo " publish Increment version, commit and push changes"
echo " audit Run CSS/Audit on public folder"
echo " Usage: ./run.sh audit [folder]"
echo " -h, --help Show this help message"
}
case "$1" in
clean)
npm run clean
;;
build)
npm run build
;;
rebuild)
npm run clean
npm run build:full
;;
test)
npm run test:local
;;
audit)
shift
folder="${1:-public}"
node scripts/audit.js "$folder"
;;
commit)
shift
msg="${1:-chore: update project build artifacts and content}"
git add .
git commit -m "$msg"
;;
publish)
VERSION_FILE="README.md"
CURRENT_VERSION=$(awk '/Version: [0-9]+\.[0-9]+\.[0-9]+/ {print $2}' "$VERSION_FILE")
if [ -z "$CURRENT_VERSION" ]; then
echo "Could not find version in $VERSION_FILE"
exit 1
fi
echo "Current version: $CURRENT_VERSION"
IFS='.' read -r major minor patch <<< "$CURRENT_VERSION"
NEW_PATCH=$((patch + 1))
NEW_VERSION="$major.$minor.$NEW_PATCH"
echo "New version: $NEW_VERSION"
# Update README
perl -pi -e "s/Version: $CURRENT_VERSION/Version: $NEW_VERSION/" "$VERSION_FILE"
# Update package.json version
node -e "const fs = require('fs'); const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); pkg.version = '$NEW_VERSION'; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');"
git add "$VERSION_FILE" package.json
git commit -m "chore: bump version to $NEW_VERSION"
git push
echo "Published version $NEW_VERSION"
;;
-h|--help|"")
show_help
;;
*)
echo "Unknown command: $1"
echo "Run './run.sh --help' for usage."
exit 1
;;
esac