Skip to content

Commit

Permalink
Move tools to tools/ dir
Browse files Browse the repository at this point in the history
And minor script changes
  • Loading branch information
stupid-genius committed Oct 6, 2024
1 parent 2cc2717 commit b8e4203
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ jobs:
git config user.name "Allen"
git config user.email "accounts@stupid-genius.com"
- name: Publish to pages branch
run: ./publish.sh
run: ./tools/publish.sh

2 changes: 1 addition & 1 deletion esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const onBuild = {
setup(build){
build.onEnd(result => {
// console.log(result);
exec('./build.sh spa', (err, stdout, stderr) => {
exec('./tools/build.sh spa', (err, stdout, stderr) => {
if(err || stderr){
console.dir(err);
console.error(stderr);
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
"mocha": "^9.2.2"
},
"scripts": {
"build": "npm run clean; ./build.sh",
"app": "npm run build; docker compose up --build; docker compose down",
"build": "npm run clean; ./tools/build.sh",
"clean": "rm -rf dist",
"cluster": "npm run build; docker compose up --build; docker compose down",
"container": "docker run --name webapp -p80:3000 --rm webapptemplate",
"esbuild": "esbuild",
"image": "docker build -t webapptemplate .",
"nodemon": "npx nodemon dist/server/index.js",
"package": "mkdir -p package; cd dist; npm pack --pack-destination='../package/'",
"start": "NODE_ENV=development ./serve.sh",
"start": "NODE_ENV=development ./tools/serve.sh",
"test": "mocha test/server && karma start"
}
}
5 changes: 4 additions & 1 deletion build.sh → tools/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ node esbuild.mjs
if [[ -z "$1" || "$1" -ne spa ]]; then
echo Full build
cp -R app/server/ dist/server/
cp .env dist/
else
echo SPA build
fi
Expand All @@ -16,5 +17,7 @@ if [ -d "app/client/images" ] && [ -n "app/client/images/*" ]; then
cp -R app/client/images dist/client/
fi
jq '{name: .name, description: .description, version: .version, dependencies: .dependencies}' package.json > dist/package.json
cp package-lock.json .env dist/
if [ "$NODE_ENV" = "production" ]; then
npm --prefix dist update --package-lock-only
fi
echo Build complete
File renamed without changes.
File renamed without changes.
6 changes: 2 additions & 4 deletions serve.sh → tools/serve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ set +a
APPPORT=3000

if [ "$NODE_ENV" = "production" ]; then
echo "NODE_ENV is set to production"
if [ -n "$SPAMODE" ]; then
npx http-server -c-1 client/ -p $APPPORT
else
Expand All @@ -21,13 +20,12 @@ else
BSPID=$!
echo BrowserSync PID $BSPID
trap "kill -0 $BSPID &> /dev/null && kill $BSPID && echo sending SIGTERM to $BSPID" INT HUP TERM QUIT ABRT EXIT
# if [[ -z "$1" || "$1" -ne spa ]]; then
if [ -n "$SPAMODE" ]; then
echo Server in SPA mode
(fswatch -ol 1 app/client | xargs -n1 -I{} ./build.sh spa) &
(fswatch -ol 1 app/client | xargs -n1 -I{} ./tools/build.sh spa) &
npx http-server -c-1 dist/client/ -p $APPPORT
else
(fswatch -ol 1 app | xargs -n1 -I{} ./build.sh) &
(fswatch -ol 1 app | xargs -n1 -I{} ./tools/build.sh) &
npm run nodemon
fi
fi
Expand Down

0 comments on commit b8e4203

Please sign in to comment.