forked from sdelements/node-slate
-
Notifications
You must be signed in to change notification settings - Fork 89
/
task-runner.sh.command
executable file
·102 lines (95 loc) · 2.77 KB
/
task-runner.sh.command
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
##############
# node-slate #
##############
# To make this file runnable:
# $ chmod +x *.sh.command
banner="node-slate"
projectHome=$(cd $(dirname $0); pwd)
webPage=build/1-dev/index.html
setupTools() {
# Check for Node.js installation and download project dependencies
cd $projectHome
echo
echo $banner
echo $(echo $banner | sed s/./=/g)
pwd
test -d .git || { echo "Project must be in a git repository."; exit; }
git restore dist/* &>/dev/null
git pull --ff-only
echo
echo "Node.js:"
which node || { echo "Need to install Node.js: https://nodejs.org"; exit; }
node --version
npm install --no-fund
npm update --no-fund
npm outdated
echo
}
releaseInstructions() {
cd $projectHome
org=$(grep git+https package.json | awk -F'/' '{print $4}')
name=$(grep '"name":' package.json | awk -F'"' '{print $4}')
package=https://raw.githubusercontent.com/$org/$name/main/package.json
version=v$(grep '"version"' package.json | awk -F'"' '{print $4}')
pushed=v$(curl --silent $package | grep '"version":' | awk -F'"' '{print $4}')
minorVersion=$(echo ${pushed:1} | awk -F"." '{ print $1 "." $2 }')
released=$(git tag | tail -1)
published=v$(npm view $name version)
test $? -ne 0 && echo "NOTE: Ignore error if package is not yet published."
echo "Local changes:"
git status --short
echo
echo "Recent releases:"
git tag | tail -5
echo
echo "Release progress:"
echo " $version (local) --> $pushed (pushed) --> $released (released) --> $published (published)"
echo
test "$version" ">" "$released" && mode="NOT released" || mode="RELEASED"
echo "Current version is: $mode"
echo
nextActionBump() {
echo "When ready to do the next release:"
echo
echo " === Increment version ==="
echo " Edit package.json to bump $version to next version number"
echo " $projectHome/package.json"
}
nextActionCommitTagPub() {
echo "Verify all tests pass and then finalize the release:"
echo
echo " === Commit and push ==="
echo " Check in all changed files with the message:"
echo " Release $version"
echo
echo " === Tag and publish ==="
echo " cd $projectHome"
echo " git tag --annotate --message 'Release' $version"
echo " git remote --verbose"
echo " git push origin --tags"
echo " npm publish"
}
test "$version" ">" "$released" && nextActionCommitTagPub || nextActionBump
echo
}
runTasks() {
cd $projectHome
echo "Tasks:"
npm test
npm run build
npx gulp publish
echo
}
openBrowser() {
cd $projectHome
echo "Opening:"
echo "$projectHome/$webPage"
echo
sleep 2
open $webPage
}
setupTools
releaseInstructions
runTasks
openBrowser